I am new to AWS CDK TypeScript.
My issue is: [Tried to create resource record set [name='xxxxx', type='CNAME'] but it already exists]"}
Using AWS CDK TypeScript I am creating stacks in eu-west1 and eu-central regions. So is there any mechanism to check if cname is not created then only create?
My code current code:
const cName = new route53.CnameRecord(this, "cName", {
zone: route53.HostedZone.fromLookup(this, "lowerHostedZone3", {
domainName: topDomain,
}),
recordName: topFQDN,
domainName: lowerFQDN
});
Deploying the stack in multiple regions will probably create the same entry twice (one for eu-west-1
and one for eu-central-1
). Since route53
is a global service, this could be the cause of the error you see.
Instead of doing a lookup you can simply choose to make 1 region leading for DNS, or include the region name in the DNS entries (my-service.eu-west-1.my-domain.com
), and then front it with something like cloudfront or global accelerator to do global routing to the nearest region.