1
0
Files
terraform.examples/modules/networking/r53-record-geo/main.tf
T
2026-02-13 15:44:24 +08:00

60 lines
1.8 KiB
Terraform

resource "aws_route53_record" "default" {
zone_id = var.zone_id
name = var.record_name
type = var.record_type
ttl = length(var.alias) > 0 ? null : var.record_ttl
records = var.record_values
set_identifier = var.set_identifier
geolocation_routing_policy {
country = "*"
}
dynamic "alias" {
for_each = var.alias
content {
name = alias.value["name"]
zone_id = alias.value["zone_id"]
evaluate_target_health = alias.value["evaluate_target_health"]
}
}
dynamic "weighted_routing_policy" {
for_each = var.weighted_routing_policy
content {
weight = weighted_routing_policy.value["weight"]
}
}
}
resource "aws_route53_record" "locational" {
zone_id = var.zone_id
name = var.record_name
type = var.record_type_locational
ttl = length(var.alias_locational) > 0 ? null : var.record_ttl_locational
records = var.record_values_locational
set_identifier = var.set_identifier_locational
dynamic "alias" {
for_each = var.alias_locational
content {
name = alias.value["name"]
zone_id = alias.value["zone_id"]
evaluate_target_health = alias.value["evaluate_target_health"]
}
}
geolocation_routing_policy {
country = var.country_code
continent = var.continent_code
}
dynamic "alias" {
for_each = var.alias_locational
content {
name = alias.value["name"]
zone_id = alias.value["zone_id"]
evaluate_target_health = alias.value["evaluate_target_health"]
}
}
dynamic "weighted_routing_policy" {
for_each = var.weighted_routing_policy_locational
content {
weight = weighted_routing_policy.value["weight"]
}
}
}