Skip to content

(acm): DomainName length check fails with too long prop due to string encoded tokens. #23565

@rv2673

Description

@rv2673

Describe the bug

When creating Certificate where the domainName property contains domain with tokens, the length check fails because the string encoded token causes the length to exceed the maximum even if token resolved to something shorter.

Expected Behavior

Check is only done when string contains no unresolved tokens.

Offending line:

if (props.domainName.length > 64) {

Current Behavior

Synthesis failed because length is exceeded due to string encoded token.

Reproduction Steps

Create cdk stack
Add Certificate where the base domain is 54 characters.
Add domainName string where subdomain comes from Token (For example CfnParameter)
Try to synthesize stack.

Possible Solution

Perform check only when tokens are unresolved. Like cdk documentation suggests.

if (props.domainName.length > 64) {

Example from docs:

if (!Token.isUnresolved(name) && name.length > 10) {
  throw new Error(`Maximum length for name is 10 characters`);
}

In this context:

if (!Token.isUnresolved(props.domainName) && props.domainName.length > 64) {
  throw new Error('Domain name must be 64 characters or less');
}

Additional Information/Context

No response

CDK CLI Version

2.58.1

Framework Version

No response

Node.js Version

16.19.0

OS

Ubuntu

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-certificatemanagerRelated to Amazon Certificate ManagerbugThis issue is a bug.effort/smallSmall work item – less than a day of effortin-progressThis issue is being actively worked on.p2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions