Skip to content

[aws-route53] Improve error message when domain for hosted zone is undefined #10053

@bahrmichael

Description

@bahrmichael

#:question: General Issue

I tried to deploy a stack that had the following code:

export class WildcardSubdomainsStack extends cdk.Stack {

  private readonly domain: string;

  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    
    const domain = `picture.bahr.dev`;
    
    // this.domain is undefined
    const hostedZone = HostedZone.fromLookup(this, 'HostedZone', { domainName: this.domain });
 }
}

I had an error there, as I should have accessed the local variable, and not the construct variable domain.

It took me however quite long to find this issue, because the error message didn't give me much information.

Cannot read property 'endsWith' of undefined
Subprocess exited with error 1
Error: Subprocess exited with error 1
    at ChildProcess.<anonymous> (/Users/michaelbahr/Documents/dev/wildcard-subdomains/node_modules/aws-cdk/lib/api/cxapp/exec.ts:118:23)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:485:12)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)

Figuring out this problem through the source code is not possible, as the mapping files for exec.ts don't seem to contain any endsWith.

The Question

Could you add some sanity checks that lead to a more descriptive error message?

Environment

  • CDK CLI Version: 1.60.0 (build 8e3f53a)
  • Module Version: 1.60
  • Node.js Version: v13.14.0
  • OS: OSX Mojave
  • Language (Version): "typescript": "~3.7.2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-route53Related to Amazon Route 53effort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions