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.fromLookup returned error

See original GitHub issue

I have a hosted zone on route53, and use the following CDK code (typescript) to look up that zone using domainName, but got error while running cdk synth, cdk diff and cdk deploy. After changing to use route53.HostedZone.fromHostedZoneAttributes(), it works.

Reproduction Steps

const zone = route53.HostedZone.fromLookup(this, 'Zone', { domainName: props.domainName });

Error Log

Cannot retrieve value from context provider hosted-zone since account/region are not specified at the stack level. Either configure "env" with explicit account and region when you define your stack, or use the environment variables "CDK_DEFAULT_ACCOUNT" and "CDK_DEFAULT_REGION" to inherit environment information from the CLI (not recommended for production stacks)
Subprocess exited with error 1

Environment

  • CLI Version : 1.19.0 (build 5597bbe)
  • Framework Version:1.19.0
  • OS :macOS Mojave version 10.14.6
  • **Language :typescript **

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:20
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ilazakiscommented, Apr 6, 2022

cdk 2.29.0

I think the reason synth succeeds while deploy fails when using HostedZoneFromLookup is that the cdk optimistically assumes a successful lookup.

Here’s the synth output for domainHostedZone.HostedZoneId() (using Golang): DUMMY

That looks like a placeholder value in case of unsuccessful lookups.

In fact, after having fought this for a couple of hours, I think the answer to “why does the zone lookup sometimes fail” in my case is eventual consistency. After deleting and recreating the stack/zone in question a few times, I went for a walk, retried and the zone was now “found”.

I have not looked into the JS or Golang implementations yet, but I suspect many may be falling victims to the CDK trying to fallback to a dummy zone instead of failing outright.

1reaction
salsa2kcommented, Jul 2, 2020

Hi, I found what is the problem:

Is related to my alias creatio. Before I was using:

     new RecordSet(this, "ApiRecordSetA", {
       zone: props.zone,
       recordName: 'sub.domain.com',
       recordType: RecordType.A,
       target: RecordTarget.fromAlias(new ApiGatewayDomain(customDomain)),
     });

I changed it to:

    new ARecord(this, "ApiRecordA", {
      zone: props.zone,
      recordName: 'sub.domain.com',
      target: RecordTarget.fromAlias(new ApiGatewayDomain(customDomain)),
    });

And now its working o0

Thanks guys

Read more comments on GitHub >

github_iconTop Results From Across the Web

class HostedZone (construct) · AWS CDK
Import a Route 53 hosted zone defined either outside the CDK, or in a different CDK stack. static fromLookup(scope, id, query), Lookup a...
Read more >
No hosted zone found with ID error when deploying
const zone = route53.HostedZone.fromLookup(this, 'Zone', { domainName: domainName });. When I deploy, I get the following error
Read more >
awslabs/aws-cdk - Gitter
Now I'm hitting this point :( const authHostedZone = route53.HostedZone.fromLookup(this, "AuthHostedZone", { domainName: authRecord // This is Token.
Read more >
aws-solutions-constructs.aws-route53-apigateway - PyPI
CDK constructs for connecting an Amazon Route53 domain to an API Gateway. ... fromLookup(this, "HostedZone", new HostedZoneProviderProps.Builder() .
Read more >
CDK domain cert setup for a static site - What must be done ...
I have purchased a domain through Route53. I have also manually created a public hosted zone for the domain. The problem I'm having...
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