funsetgroup = template.add_resource(RecordSet(
'funsetgroup',
HostedZoneName=Join('', [Ref(hostedzone), "."]),
Comment='Hosted Zone Name',
Type="A",
Name=Join('fun.', [Ref(hostedzone), "."]),
AliasTarget=AliasTarget(
HostedZoneId=GetAtt(myelb, "CanonicalHostedZoneNameID"),
DNSName=GetAtt(myelb, "DNSName"),
)))
In this troposphere code I am trying to create an Alias A record for my hosted zone say, example.com. But I have 2 hosted zones with the same name(hosted zone Id's will be different). Although I explicitly mention the hosted zone id cloud formation doesn't create the stack saying "duplicate hosted zone found". I also tried just mentioning the hosted zone id without the hostedzone name that fails as well.
Did you also try using HostedZoneId
instead of HostedZoneName
in the RecordSet? This should work - we created Alias records in different zones with the same name in Empire all the time, and our code there uses Cloudformation as well (with a shim similar to troposphere - so much so, we call it troposphere). You can see that here:
Doing something similar in troposphere should work fine - just use HostedZoneId both in the RecordSet and the AliasTarget objects.