I have an existing domain name registered with AWS Route53 and I have set up a custom domain name in API Gateway. In the console i can configure things such that xxxxxx.zenxxxxxxfoundry.com from the outside, actually reaches the API Gateway API and then on through to my Lambda functions.
Now I want to achieve this with AWS CDK.
I have tried the following:
const zone = route53.HostedZone.fromHostedZoneId(this, 'ZenithWebFoundryZone', 'ZXXXXXX04V8134');
new route53.AliasRecord(this, 'BlogAPIRecord', {
zone: zone,
recordName: 'xxxxxx.zenxxxxxxfoundry.com',
target: {
bind: (): route53.AliasRecordTargetProps => ({
dnsName: 'd-xxxxxxy00g.execute-api.ap-southeast-2.amazonaws.com',
hostedZoneId: 'ZXXXXXX04V8134'
})
}
});
which builds ok npm run build
but when I run cdk synth
I get the rather obtuse error:
$ cdk synth
HostedZone.fromHostedZoneId doesn't support "zoneName"
Subprocess exited with error 1
Switching on --trace
didn't really help much: the additional info:
Error: Subprocess exited with error 1
at ChildProcess.proc.on.code (/Users/mikecoxon/.npm-packages/lib/node_modules/aws-cdk/lib/api/cxapp/exec.ts:108:23)
at ChildProcess.emit (events.js:189:13)
at ChildProcess.EventEmitter.emit (domain.js:441:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
I have looked through the whole stack script and there is no reference to zoneName
anywhere. Does anyone know where this error comes from?