question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue when using "route53.HostedZone.fromHostedZoneId" Method

See original GitHub issue

Reproduction 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:23 (6 by maintainers)

github_iconTop GitHub Comments

21reactions
justin-adcommented, Jul 21, 2021

I’m resolving this issue as I don’t believe further action is required.

Feel free to re-open / ask questions if anything has been left unanswered!

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.

10reactions
shivlakscommented, Jun 9, 2020

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(...) and fromHostedZoneName(...) 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 populate cdk.context.json.

It takes the attributes and performs an API call to determine which exact HostedZone is deployed and updates its behavior accordingly.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found