Issue when using "route53.HostedZone.fromHostedZoneId" Method
See original GitHub issueReproduction Steps
When trying to import an HostedZone with :
route53.HostedZone.fromHostedZoneId(this, 'MyHostedZone', 'ID123456789')
Error Log
I’ve that error when launching the Stack :
HostedZone.fromHostedZoneId doesn't support "zoneName"
Environment
- CLI Version : CDK 1.42.1 (build a4797b4)
- Framework Version: 6.14.5
- Node.js Version: v12.15.0
- OS : Linux
- Language (Version): TypeScript
Other
So, I’ve imported that way :
route53.HostedZone.fromHostedZoneAttributes(this, 'R53Domain', {hostedZoneId: 'MyID123456789', zoneName: 'Toto'})
What’s wrong with fromHostedZoneId Method ?
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:23 (6 by maintainers)
Top Results From Across the Web
class HostedZone (construct) · AWS CDK
Imports a hosted zone from another stack. static fromHostedZoneId(scope, id, hostedZoneId), Import a Route 53 hosted zone defined either outside the CDK, or...
Read more >awslabs/aws-cdk - Gitter
it seems to me that we have another classic CDK chicken and egg problem. IHostedZone object is created using lookup method but during...
Read more >AWS CDK: how to target API Gateway API from Route53
I was facing the same issue using cdk 1.36.1 and managed to solve it using a new Custom Domain Name in ApiGateway, together...
Read more >@aws-cdk/aws-route53 NPM | npm.io
Alternatively, use the HostedZone.fromHostedZoneId to import hosted zones if you know the ID and the retrieval for the zoneName is undesirable. const zone...
Read more >aws-cdk/aws-route53/README.md - UNPKG
The CDN for @aws-cdk/aws-route53. ... 24, To add a private hosted zone, use `PrivateHostedZone`. Note that ... fromHostedZoneId` to import hosted zones if....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve encountered this issue just now and I believe this should be reopened @shivlaks
Why would the following call (I’m using Python CDK v1.114.0):
route53.HostedZone.from_hosted_zone_id(self, "MyHostedZone", hosted_zone_id="MyHostedZoneId")
Result in:
Error: HostedZone.fromHostedZoneId doesn't support "zoneName"
This doesn’t make sense… I didn’t pass the function a zone name and in fact the function doesn’t even accept a zone name… This is either poor API design, or a bug - calling this expected behavior seems like a stretch to me.
What you’re currently doing is fine. I do believe we can better document this as it has come up before as a point of confusion for users.
fromHostedZoneId(...)
andfromHostedZoneName(...)
will create a mock object with just the ZoneId or the ZoneName field present. These are useful if you need to supply a HostedZone object but you know that the resource that is accepting the HostedZone only needs access to one of those variables. This is done without having make an API call so it can be done entirely locally.fromHostedZoneAttributes
will actually make a call to AWS to retrieve information and populatecdk.context.json
.It takes the attributes and performs an API call to determine which exact HostedZone is deployed and updates its behavior accordingly.