I'm trying to use ansible to provision Route53 failover (although the fact I'm using ansible isn't particularly relevant).
I have this task that works:
- name: Route 53 Failover | Add ALIAS
route53:
command: create
zone: "{{ top_level_domain }}"
record: "{{ cname_record_domain }}"
type: A
alias: true
alias_hosted_zone_id: "Z2FDTNDATAQYW2"
value: "{{ cname_target_domain }}"
wait: yes
failover: SECONDARY
identifier: "{{ cname_record_identifier }}"
overwrite: true
The hard coded alias_hosted_zone_id
is the hosted zone of my cloudfront distribution. The only way to find this (that I'm aware of) is to choose the cloudfront distribution as an alias in the "Add record set" dialog of the Route53 console. It then states the hosted zone in the dialog.
What I would like to do is replace the hard coded string with a variable that is populated from an aws cli
command or ansible task. Is this possible?
For CloudFront distributions, the value is always Z2FDTNDATAQYW2
(at the time of writing).
An actual citation from the Route 53 documentation itself proved more elusive than I expected -- there are (as of this writing) some search engine false-hits for this string (presumably there's some refactoring of the docs going on), but see, for example http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget.html.