aws / aws/aws-cdk

cli: inform user when deployment fails due to value stored in cdk.context.json

Open
#23,437 7 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-route53 effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

I ran into a 404 error after manually deleting a hosted zone created by CDK, recreating the zone with the AWS console and then trying to look up the zone with the CDK by name. The lookup fails with a 404 trying to find a zone with a wrong ID.

### Expected Behavior

The CDK should be able to find the zone.

### Current Behavior

No hosted zone found with ID: Z049836444COOXK7EL2O (Service: AmazonRoute53; Status Code: 404; Error Code: NoSuchHostedZone; Request ID: fffc8a5a-8e70-4c40-b83b-e1d7946735e8; Proxy: null)

### Reproduction Steps

1. Create a hosted zone with CDK.
2. Delete it manually and recreate it manually in the AWS Console.
3. Lookup the zone with CDK by name.

### Possible Solution

I used grep and found the old ID in a file called `cdk.context.json`. After deleting the file I was able to deploy my stack again. The file got recreated and now contains the current ID of the hosted zone.

What's the reason to write the HostedZone into this file? If it's caching, maybe it can get cached somewhere else, i.e. `cdk.out/.cache` or something like that? The CDK should also repeat the lookup without the cache in case of a 404.

If all that isn't possible, maybe the CDK should point you in case of a failed lookup to a troubleshooting guide.

### Additional Information/Context

Deleting `cdk.out` and `__pycache__` doesn't solve the problem.

### CDK CLI Version

2.56.0 (build 1485f48)

### Framework Version

_No response_

### Node.js Version

v18.12.1

### OS

Fedora Linux 37

### Language

Python

### Language Version

3.11.0

### Other information

Here is why I deleted and recreated the hosted zone manually with the AWS console: I first created a hosted zone for my TLD with CDK. Then I realized that it's better to have a [hosted zone for the subdomain](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-routing-traffic-for-subdomains.html) in my use-case. So I deleted the one created by the CDK and created a new one using the AWS console. Then I changed my CDK template to create the zone for my subdomain and lookup the one for the TLD to add a delegation NS record there.

Contributor guide

Open the contributing guide

Research direction

Start with the CDK CLI deployment flow and the cdk.context.json entry that stores the hosted zone ID. Reproduce the hosted-zone lookup after deleting and recreating the zone, then determine how the CLI should report the stale lookup result; done should include a clear failure message or troubleshooting guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cli, cloud
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.