aws / aws/aws-cdk

aws-route53: Can't update existing CNAME without recreating resource

Open
#34,918 6 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-route53 bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

Consider we created a custom domain like:
```
new CnameRecord(this, 'CNameRecord', {
recordName: `${serviceName}`,
domainName: domainNameAliasDomainName,
ttl: ttl,
zone: externalHostZone,
});
```

This domain points to a custom Rest API GW domain (for example).
We created a new version of this service, and now we want to migrate the new version by pointing the existing CName to the new API Gw custom domain (deployed in parallel to the existing one).

In order to do that, we simply change the `domainName` property in the existing CName construct.

The same update works for ARecord though.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Library Version

2.149.0

### Expected Behavior

I'm aware of `deleteExisting` flag, but would like to avoid setting it to true, as it is a dangerous setting for production stage (destroys existing cname before creating a new one), we'd like to be able to simply update the CName settings without destroying it, as the resource is already defined within an existing stack.

### Current Behavior

The CName update fails with the following error:
`domainName` already exists in stack arn:aws:cloudformation:region:account:stack/stackName/uuid

### Reproduction Steps

- Create a CName record in a stack and point it to an existing api gw.
- Change the CName construct to point to a new api gw domain.

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS CDK Library version (aws-cdk-lib)

2.149.0

### AWS CDK CLI version

2.16.9

### Node.js Version

20

### OS

linux

### Language

TypeScript

### Language Version

5.8.0

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the update using the TypeScript CnameRecord construct described in the issue, changing domainName from one API Gateway custom domain to another. Trace the aws-route53 resource update behavior and compare it with ARecord handling. Done means an existing CNAME can change targets without deleting it first or requiring deleteExisting, with regression coverage for the reported scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.