Issue with ACM Certs and Route53 in cdktf

Hey,

I have been trying to create a ACM Cert and use the domain validation options to create the route53 configuration but I’m getting this error:

Error: Invalid index

  on cdk.tf.json line 91, in resource.aws_route53_record.fresh-paint-dns-record:
  91:         "type": "${aws_acm_certificate.fresh-paint-cert.domain_validation_options.0.resource_record_type}",

This value does not have any indices.

I’m using the typescript cdk and have created this function:

export function createCertAndRecord(
  scope: Construct,
  provider: AwsProvider,
  domainName: string,
  zoneId: string
) {
  const cert = new AcmCertificate(scope, "cert", {
    provider,
    domainName,
    validationMethod: "DNS",
    lifecycle: {
      createBeforeDestroy: true,
    },
  });

  const { fqdn } = new Route53Record(scope, "dns-record", {
    allowOverwrite: true,
    name: cert.domainValidationOptions("0").resourceRecordName,
    type: cert.domainValidationOptions("0").resourceRecordType,
    records: [cert.domainValidationOptions("0").resourceRecordValue],
    zoneId,
    ttl: 300,
  });

  new AcmCertificateValidation(scope, "cert-validation", {
    provider,
    certificateArn: cert.arn,
    validationRecordFqdns: [fqdn],
  });

  return cert;
}

Other than the life cycle it seems to be very similar to this example.

Here are the versions of cdktf and the aws provider that I’m using (I get the same error with the generated version.)

@cdktf/provider-aws: 1.0.28
cdktf 0.2.0

Any help with this would be greatly appreciated.

Support for this is a bit sub-par at this time, but take a look at this issue for some workarounds.