Skip to content

Commit

Permalink
Route53 record length fix (#59)
Browse files Browse the repository at this point in the history
* added local variable to calculate the length of records in route53
- If a record in var.records is longer than 255 characters, we split the record every 255 characters with \"\" between each 255th and 256th character.

* added header comments
  • Loading branch information
zachreborn committed Apr 2, 2024
1 parent 2213577 commit 67d19c5
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 5 deletions.
17 changes: 17 additions & 0 deletions modules/aws/route53/alias_record/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,6 +11,20 @@ terraform {
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################


###########################
# Module Configuration
###########################

resource "aws_route53_record" "this" {
zone_id = var.zone_id
name = var.name
Expand Down
24 changes: 23 additions & 1 deletion modules/aws/route53/failover_routing_record/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,12 +11,31 @@ terraform {
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################

locals {
# If a record in var.records is longer than 255 characters, we split the record every 255 characters with \"\" between each 255th and 256th character.
# See https://github.com/hashicorp/terraform-provider-aws/issues/14941 for more information
records = [for record in var.records : replace(record, "/(.{255})/", "$1\"\"")]
}

###########################
# Module Configuration
###########################

resource "aws_route53_record" "this" {
zone_id = var.zone_id
name = var.name
type = var.type
ttl = var.ttl
records = var.records
records = local.records

set_identifier = var.set_identifier
health_check_id = var.health_check_id
Expand Down
24 changes: 23 additions & 1 deletion modules/aws/route53/geolocation_routing_record/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,12 +11,31 @@ terraform {
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################

locals {
# If a record in var.records is longer than 255 characters, we split the record every 255 characters with \"\" between each 255th and 256th character.
# See https://github.com/hashicorp/terraform-provider-aws/issues/14941 for more information
records = [for record in var.records : replace(record, "/(.{255})/", "$1\"\"")]
}

###########################
# Module Configuration
###########################

resource "aws_route53_record" "this" {
zone_id = var.zone_id
name = var.name
type = var.type
ttl = var.ttl
records = var.records
records = local.records

set_identifier = var.set_identifier
health_check_id = var.health_check_id
Expand Down
24 changes: 23 additions & 1 deletion modules/aws/route53/latency_routing_record/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,12 +11,31 @@ terraform {
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################

locals {
# If a record in var.records is longer than 255 characters, we split the record every 255 characters with \"\" between each 255th and 256th character.
# See https://github.com/hashicorp/terraform-provider-aws/issues/14941 for more information
records = [for record in var.records : replace(record, "/(.{255})/", "$1\"\"")]
}

###########################
# Module Configuration
###########################

resource "aws_route53_record" "this" {
zone_id = var.zone_id
name = var.name
type = var.type
ttl = var.ttl
records = var.records
records = local.records

set_identifier = var.set_identifier
health_check_id = var.health_check_id
Expand Down
7 changes: 7 additions & 0 deletions modules/aws/route53/registered_domain/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -12,6 +15,10 @@ terraform {
# Data Sources
###########################

###########################
# Locals
###########################

########################################
# Route 53 Registered Domains
########################################
Expand Down
24 changes: 23 additions & 1 deletion modules/aws/route53/simple_record/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,12 +11,31 @@ terraform {
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################

locals {
# If a record in var.records is longer than 255 characters, we split the record every 255 characters with \"\" between each 255th and 256th character.
# See https://github.com/hashicorp/terraform-provider-aws/issues/14941 for more information
records = [for record in var.records : replace(record, "/(.{255})/", "$1\"\"")]
}

###########################
# Module Configuration
###########################

resource "aws_route53_record" "this" {
zone_id = var.zone_id
name = var.name
type = var.type
ttl = var.ttl
records = var.records
records = local.records

health_check_id = var.health_check_id
}
25 changes: 24 additions & 1 deletion modules/aws/route53/weighted_routing_record/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
###########################
# Provider Configuration
###########################

terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,12 +12,31 @@ terraform {
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################

locals {
# If a record in var.records is longer than 255 characters, we split the record every 255 characters with \"\" between each 255th and 256th character.
# See https://github.com/hashicorp/terraform-provider-aws/issues/14941 for more information
records = [for record in var.records : replace(record, "/(.{255})/", "$1\"\"")]
}

###########################
# Module Configuration
###########################

resource "aws_route53_record" "this" {
zone_id = var.zone_id
name = var.name
type = var.type
ttl = var.ttl
records = var.records
records = local.records

set_identifier = var.set_identifier
health_check_id = var.health_check_id
Expand Down
15 changes: 15 additions & 0 deletions modules/aws/route53/zone/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,6 +11,18 @@ terraform {
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################

###########################
# Module Configuration
###########################
resource "aws_route53_zone" "zone" {
for_each = var.zones
comment = each.value.comment
Expand Down

0 comments on commit 67d19c5

Please sign in to comment.