Skip to content

aws/edge: PublicCertificate synthesis fails when domainName comes from DnsZone.fromZoneId (Token cannot be used as construct id) #41

@zackhee997

Description

@zackhee997

Description

Using PublicCertificate with DNS validation and a domainName obtained from DnsZone.fromZoneId() causes synthesis to abort with the error:

Error: You cannot use a token (e.g., a reference to an attribute) as the id of a construct.
Ids of constructs must be known at synthesis time, and token values are only known when
Terraform runs. Please use a concrete value for your construct's ID instead.

You passed the following id: "ValidationRecord-${TfToken[TOKEN.1195]}"

The failure stems from the construct building a RecordSet like

new RecordSet(this, \ValidationRecord-${domainName}`, …)`.

ref: https://github.com/TerraConstructs/base/blob/main/src/aws/edge/certificate.ts#L255

Steps to Reproduce:

const albZone = DnsZone.fromZoneId(this, `alb-zone`, props.appHostedZoneId);

const cert = new PublicCertificate(this, 'cert', {
    domainName: albZone.zoneName,
    validation: {
        method: ValidationMethod.DNS,
        hostedZone: albZone,
    },
});
``

Assumption:
When I am using the **DnsZone.fromZoneId**, the domainName/zoneName is a token during synth. 
The interpolated ID itself becomes a token, which the CDK/Terraform adapter rejects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions