lib/terraforming/template/tf/route53_record.erb
<% records.each do |r| -%>
<%- record, zone_id = r[:record], r[:zone_id] -%>
<%- counter = r[:counter] -%>
resource "aws_route53_record" "<%= module_name_of(record, counter) %>" {
zone_id = "<%= zone_id %>"
name = "<%= name_of(record.name.sub(/\\052/, '*')) %>"
type = "<%= record.type %>"
<%- unless record.resource_records.empty? -%>
records = <%= record.resource_records.map(&:value).to_s %>
<%- end -%>
<%- if record.ttl -%>
ttl = "<%= record.ttl %>"
<%- end -%>
<%- if record.weight -%>
weighted_routing_policy {
weight = <%= record.weight %>
}
<%- end -%>
<%- if record.region -%>
latency_routing_policy {
region = "<%= record.region %>"
}
<%- end -%>
<%- if record.geo_location -%>
geolocation_routing_policy {
<%- if record.geo_location.continent_code -%>
continent = "<%= record.geo_location.continent_code %>"
<%- end -%>
<%- if record.geo_location.country_code -%>
country = "<%= record.geo_location.country_code %>"
<%- end -%>
<%- if record.geo_location.subdivision_code -%>
subdivision = "<%= record.geo_location.subdivision_code %>"
<%- end -%>
}
<%- end -%>
<%- if record.set_identifier -%>
set_identifier = "<%= record.set_identifier %>"
<%- end -%>
<%- if record.health_check_id -%>
health_check_id = "<%= record.health_check_id %>"
<%- end -%>
<%- if record.failover -%>
failover_routing_policy {
type = "<%= record.failover %>"
}
<%- end -%>
<%- if record.alias_target -%>
alias {
name = "<%= name_of(record.alias_target.dns_name)
%>"
zone_id = "<%= record.alias_target.hosted_zone_id %>"
evaluate_target_health = <%= record.alias_target.evaluate_target_health %>
}
<%- end -%>
}
<% end -%>