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?
the alias target name does not lie within the target zone
My ansible closely resembles what you have above with the alias_hosted_zone_id, any advice? My previous task creates a cloudfront_distribution, is there a value which I can use from that task to input into the route53 task?