Skip to content

HostedZone: Default period at the end should be optional #22406

@DavidA94

Description

@DavidA94

Describe the bug

In the HostedZone constructor, a period is added to the end of the name on line 163.

This changes the user's input from github.com to github.com.. Although Route53 considers these to be identical, they cannot co-exist together. Thus, for anybody moving from CFN templates to CDK, who did not have a . at the end of their name, this line breaks their CloudFormation deployment.

Consider a user who has a CloudFormation template with the following:

CustomHostedZone:
    Type: AWS::Route53::HostedZone
    Properties:
        Name: github.com
        ...

Who then re-creates their resource in CDK, keeping the same LogicalId for the migration

new HostedZone(this, "CustomHostedZone", {
    zoneName: 'github.com'
    ...
}
overrideLogicalId("CustomHostedZone");

Because the . is added, CloudFormation will see this as a name change, and try to re-create the resource. However, Route53 will see the same domain name and block the creation because the domain already exists. Because this added . is by default, the user is only left with hacky solutions to deploy their code.

Expected Behavior

Give the user an option whether or not the . should be added at the end

Current Behavior

The user has no control over the behavior.

Reproduction Steps

Create a hosted zone with a CFN template with no trailing ., and then try to create the same HostedZone, with the LogicalId overwritten, using CDK.

Possible Solution

At this point, I believe the only viable solution is a flag (addTrailingDot?) added to the properties which is defaulted to true. Unfortunately, removing this behavior outright will break anybody's code who didn't have pre-existing resources.

If github.com. exists in a user's Route53 domain list, and the . is removed from a later release of this package, then their CDK will start deploying as github.com, which will still cause CloudFormation to try to re-create the resource, causing the same issue.

Additional Information/Context

No response

CDK CLI Version

2.43.1

Framework Version

No response

Node.js Version

14

OS

Mac

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-route53Related to Amazon Route 53bugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions