Reputation: 21436
I'd like to create an internally well-known dns name that points to the ELB of my (internal ELBScheme) elastic beanstalk environment that's hosting an internal REST API.
I tried adding an .ebextensions entry that looked like this:
"eb-env-dns-name" : {
"Type" : "AWS::Route53::RecordSetGroup",
"Properties" : {
"HostedZoneName" : "mydomain.com.",
"Comment" : "alias targeted to elastic beanstalk LoadBalancer.",
"RecordSets" : [
{
"Name" : "eb-env.mydomain.com.",
"Type" : "A",
"AliasTarget" : {
"HostedZoneId" : "ABC123XYZ",
"DNSName" : { "Fn::GetAtt" : ["AWSEBLoadBalancer","DNSName"] }
}
}
]
}
}
The idea being that I could then access my internal application by making REST calls against the domain "eb-env.mydomain.com".
It didn't fail, but didn't work either: nothing showed up in my hosted zone on Route53.
I'm having trouble finding useful documentation on this stuff - can anyone point me at an example of how I might do this with the .ebextensions mechanism? Or should I be just scripting the DNS name up separately?
Upvotes: 1
Views: 1470
Reputation: 18918
In the alias target section can you try using Canonical Hosted Zone ID. Do you already have the following in the ebextension or am I missing something.
"HostedZoneId" : { "Fn::GetAtt" : ["AWSEBLoadBalancer","CanonicalHostedZoneNameID"] }
Documentation: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html
Upvotes: 1
Reputation: 21436
Realised I was going to the wrong way putting an environment specific resource into ebextensions (plus a bunch of other things wrong with the snippet in the question mean it would never work).
This is what I ended up with that works for my use case. This way I get a unique URL per environment, based on the environment name (different, readable and obbviously named urls for integration, uat and production environments).
Resources: {
"dnsResourceNname" : {
"Type" : "AWS::Route53::RecordSet",
"Properties" : {
"HostedZoneName" : "mydomain.com.",
"Comment" : "DNS name for envornment ELB.",
"Name" : {
"Fn::Join" : [ "", [
{ "Ref" : "AWSEBEnvironmentName" },
".mydomain.com."
] ]
},
"Type" : "CNAME",
"TTL" : "900",
"ResourceRecords" : [ { "Fn::GetAtt" : ["AWSEBLoadBalancer","DNSName"] } ]
}
}
}
Upvotes: 1