cdk 0.35.0
new route53.ARecord(this, "ARecordSubdomains", {
recordName: "*",
zone: hostedZone,
target: route53.RecordTarget.fromAlias(new route53targets.CloudFrontTarget(cloudFrontDistribution))
});
Gives FATAL problem: DomainLabelEmpty (Domain label is empty) encountered with '*.domain.com.' (Service: AmazonRoute53; Status Code: 400; Error Code: InvalidInput; Request ID: 581858c8-9727-11e9-b5ad-9bb4ba65f088)
Hi Alex,
Thank you for reporting this. We have limited time to try to repro and address bugs, so I would appreciate a little more information from you before we look into this.
The issue template when you create a new issue should walk you through the information we need (OS version, intended behavior, etc.).
Thanks!
OS: Windows 10
Version: 0.35.0
Intended behaviour: Should allow using wildcard record name in ARecord.
My workaround is a CfnRecordSetGroup:
new route53.CfnRecordSetGroup(this, props.domainName, {
hostedZoneName: hostedZone.zoneName,
recordSets: [
{
name: `${props.domainName}`,
type: "A",
aliasTarget: { dnsName: cloudFrontDistribution.domainName, hostedZoneId: CloudFrontHostedZoneId }
},
{
name: `*.${props.domainName}`,
type: "A",
aliasTarget: { dnsName: cloudFrontDistribution.domainName, hostedZoneId: CloudFrontHostedZoneId }
}
]
});
Looking at the Route53 documentation, it appears that you cant use an * in the leftmost label of domain names of hosted zones or records ("*.example.com" is not allowed), and even in other locations it is not treated as a wildcard. Unfortunately, if the service does not support the feature, we generally can't either.
If you would like to put in a request to the Route53 team, I recommend taking a look at their forums.
I'm sorry I can't offer more, but please let me know if this helped or you need more information.
@NGL321
The documentation you linked specifically makes 2 distinctions: Hosted Zones & Records.
For Hosted Zones, * cannot be used as a wildcard.
For Records, usage of the wildcard * is detailed there with restrictions on how it can be used. It can be used in the way I have stated (as the leftmost label in a domain name).
You can take a look at the example I gave with plain Cloudformation. This example works and demonstrates usage of a wildcard in a Record name.
Any update on this? Would be nice to be able to use the higher level construct.
My workaround is a CfnRecordSetGroup:
Thanks for this @AlexCheema, was helpful for me getting unblocked with Python.
Getting the same error with following code:
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: false
});
const zone = HostedZone.fromHostedZoneAttributes(this, 'zone', {
hostedZoneId: '*hidden*',
zoneName: '*hidden*'
});
new ARecord(this, 'Alias', {
zone: zone,
target: RecordTarget.fromAlias(new LoadBalancerTarget(lb)),
recordName: 'api'
});
Any suggestions on how to fix this?
Seems to be fixed by using the full record name (e.g. 'subdomain.domain.com.') instead of only subdomain. Still I think this is a bug, since only subdomain should also work according to CDK documentation.
Most helpful comment
My workaround is a CfnRecordSetGroup: