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.

Route53: HostedZone.fromHostedZoneId() throws an error for cdk synth

See original GitHub issue
  • I’m submitting a …

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior? If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce

Example code:

const domainZone = route53.HostedZone.fromHostedZoneId(this, 'domain-zone', hostedZoneId);

cdk synth throws an error:

HostedZone.fromHostedZoneId doesn't support "zoneName"
  • What is the expected behavior (or behavior of feature suggested)?

fromHostedZoneId() should return a valid IHosted­Zone object.

  • What is the motivation / use case for changing the behavior or adding this feature?

HostedZone is needed, for instance, for LoadBalancedFargateServiceProps (for the domainZone property).

  • Please tell us about your environment:

    • CDK CLI Version: 1.4.0 (build 175471f)
    • Module Version: 1.4.0
    • OS: OSX Mojave
    • Language: TypeScript
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:17
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

27reactions
rhboydcommented, Aug 26, 2019

@realharry for Hosted Zones there are 3 methods that accomplish very similar, but slightly different goals.

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.

The third method is fromAttributes(...) that will take the attributes and perform an API call to determine which exact HostedZone is deployed and updates its behavior accordingly.

The first two methods create use different Classes of IHostedZone that throw an error if you use the wrong parameter (e.g. calling getName() when you used fromHostedZoneId())

12reactions
kevinjamescaseycommented, Nov 1, 2021

I just fell into the same trap two years after this problem was first reported. It would be nice if the docs were updated so everybody didn’t have to get the error, search for it on google, and read a bunch of threads to find the explanation of this wacky function.

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 >
@aws-cdk/aws-route53 | Yarn - Package Manager
To add a public hosted zone: new route53.PublicHostedZone(this, 'HostedZone', { zoneName: 'fully.qualified.domain.com' ...
Read more >
AWS CDK, creating an alias record for an existing hosted ...
I tested with AWS CDK version 1.5.0 (build c020efa) and 1.6.0 (build 3a0cde0). I tried finding the zone like so: zone = route53.HostedZone...
Read more >
awslabs/aws-cdk - Gitter
Can someone please look and tell me what I am doing wrong. getting this error, init() takes 3 positional arguments but 4 were...
Read more >
CDKでFargateを作成する - Zenn
AWS CDKアプリには、cdk synthする時に外部問い合わせを必要とするコードを ... fromLookup()などの呼び出しで参照できます。 ... Error: HostedZone.
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