NEW: r53 record modules
This commit is contained in:
parent
7c8ba23190
commit
b37b681657
18
modules/networking/r53-record-geo/README.md
Normal file
18
modules/networking/r53-record-geo/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# r53-record-geo sub module
|
||||
Create route53 geolocation records
|
||||
|
||||
## Example
|
||||
```hcl
|
||||
module "georecord" {
|
||||
source = "./submodule/r53-record-geo"
|
||||
record_name = "products"
|
||||
record_type = "A"
|
||||
record_values = ["1.2.3.4"]
|
||||
set_identifier = "DNS record for unspecified locations"
|
||||
record_type_locational = "A"
|
||||
record_values_locational = ["5.6.7.8"]
|
||||
set_identifier_locational = "DNS record for China"
|
||||
country_code = "CN"
|
||||
zone_id = "r53-zone-id"
|
||||
}
|
||||
```
|
60
modules/networking/r53-record-geo/main.tf
Normal file
60
modules/networking/r53-record-geo/main.tf
Normal file
@ -0,0 +1,60 @@
|
||||
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"]
|
||||
}
|
||||
}
|
||||
}
|
62
modules/networking/r53-record-geo/variables.tf
Normal file
62
modules/networking/r53-record-geo/variables.tf
Normal file
@ -0,0 +1,62 @@
|
||||
variable "zone_id" {}
|
||||
variable "record_name" {}
|
||||
variable "record_type" {}
|
||||
variable "record_ttl" {
|
||||
type = number
|
||||
default = 900
|
||||
}
|
||||
variable "record_values" {
|
||||
type = list(string)
|
||||
}
|
||||
variable "set_identifier" {}
|
||||
variable "alias" {
|
||||
type = list(
|
||||
object({
|
||||
zone_id = string
|
||||
name = string
|
||||
evaluate_target_health = bool
|
||||
})
|
||||
)
|
||||
}
|
||||
variable "weighted_routing_policy" {
|
||||
type = list(
|
||||
object({
|
||||
weight = number
|
||||
})
|
||||
)
|
||||
default = []
|
||||
}
|
||||
variable "record_type_locational" {}
|
||||
variable "record_ttl_locational" {
|
||||
type = number
|
||||
default = 900
|
||||
}
|
||||
variable "record_values_locational" {
|
||||
type = list(string)
|
||||
}
|
||||
variable "set_identifier_locational" {}
|
||||
variable "country_code" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
variable "continent_code" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
variable "alias_locational" {
|
||||
type = list(
|
||||
object({
|
||||
zone_id = string
|
||||
name = string
|
||||
evaluate_target_health = bool
|
||||
})
|
||||
)
|
||||
}
|
||||
variable "weighted_routing_policy_locational" {
|
||||
type = list(
|
||||
object({
|
||||
weight = number
|
||||
})
|
||||
)
|
||||
default = []
|
||||
}
|
30
modules/networking/r53-record/README.md
Normal file
30
modules/networking/r53-record/README.md
Normal file
@ -0,0 +1,30 @@
|
||||
# r53-record sub module
|
||||
Create route53 record
|
||||
|
||||
## Example
|
||||
```hcl
|
||||
module "r53-ftp" {
|
||||
source = "../../modules/networking/r53-record"
|
||||
|
||||
record_name = "ftp"
|
||||
record_type = "A"
|
||||
record_values = ["192.168.0.100"]
|
||||
zone_id = aws_route53_zone.zone.zone_id
|
||||
}
|
||||
|
||||
module "r53-www" {
|
||||
source = "../../modules/networking/r53-record"
|
||||
|
||||
record_name = "www"
|
||||
record_type = "A"
|
||||
record_values = null
|
||||
alias = [
|
||||
{
|
||||
zone_id = "Z2LIHJ7PKBEMWN"
|
||||
name = "vpce-07b8a9af30673995f-2n2ird8h.ssm.ap-east-1.vpce.amazonaws.com"
|
||||
evaluate_target_health = true
|
||||
}
|
||||
]
|
||||
zone_id = aws_route53_zone.zone.zone_id
|
||||
}
|
||||
```
|
22
modules/networking/r53-record/main.tf
Normal file
22
modules/networking/r53-record/main.tf
Normal file
@ -0,0 +1,22 @@
|
||||
resource "aws_route53_record" "this" {
|
||||
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
|
||||
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"]
|
||||
}
|
||||
}
|
||||
}
|
32
modules/networking/r53-record/variables.tf
Normal file
32
modules/networking/r53-record/variables.tf
Normal file
@ -0,0 +1,32 @@
|
||||
variable "zone_id" {}
|
||||
variable "record_name" {}
|
||||
variable "record_type" {}
|
||||
variable "record_ttl" {
|
||||
type = number
|
||||
default = 900
|
||||
}
|
||||
variable "record_values" {
|
||||
type = list(string)
|
||||
}
|
||||
variable "set_identifier" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "alias" {
|
||||
type = list(
|
||||
object({
|
||||
zone_id = string
|
||||
name = string
|
||||
evaluate_target_health = bool
|
||||
})
|
||||
)
|
||||
default = []
|
||||
}
|
||||
variable "weighted_routing_policy" {
|
||||
type = list(
|
||||
object({
|
||||
weight = number
|
||||
})
|
||||
)
|
||||
default = []
|
||||
}
|
Loading…
Reference in New Issue
Block a user