Skip to content

Commit

Permalink
feat: Add IPv6 support (ALB and Route53 AAAA record) (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
bodgit authored Apr 1, 2022
1 parent 43a0f71 commit 6cefda0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ allow_github_webhooks = true
| [aws_lb_listener_rule.unauthenticated_access_for_cidr_blocks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule) | resource |
| [aws_lb_listener_rule.unauthenticated_access_for_webhook](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule) | resource |
| [aws_route53_record.atlantis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_route53_record.atlantis_aaaa](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_ssm_parameter.atlantis_bitbucket_user_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
| [aws_ssm_parameter.atlantis_github_user_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
| [aws_ssm_parameter.atlantis_gitlab_user_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
Expand All @@ -294,6 +295,7 @@ allow_github_webhooks = true
| <a name="input_alb_http_security_group_tags"></a> [alb\_http\_security\_group\_tags](#input\_alb\_http\_security\_group\_tags) | Additional tags to put on the http security group | `map(string)` | `{}` | no |
| <a name="input_alb_https_security_group_tags"></a> [alb\_https\_security\_group\_tags](#input\_alb\_https\_security\_group\_tags) | Additional tags to put on the https security group | `map(string)` | `{}` | no |
| <a name="input_alb_ingress_cidr_blocks"></a> [alb\_ingress\_cidr\_blocks](#input\_alb\_ingress\_cidr\_blocks) | List of IPv4 CIDR ranges to use on all ingress rules of the ALB. | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
| <a name="input_alb_ip_address_type"></a> [alb\_ip\_address\_type](#input\_alb\_ip\_address\_type) | The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4 and dualstack | `string` | `"ipv4"` | no |
| <a name="input_alb_listener_ssl_policy_default"></a> [alb\_listener\_ssl\_policy\_default](#input\_alb\_listener\_ssl\_policy\_default) | The security policy if using HTTPS externally on the load balancer. [See](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html). | `string` | `"ELBSecurityPolicy-2016-08"` | no |
| <a name="input_alb_log_bucket_name"></a> [alb\_log\_bucket\_name](#input\_alb\_log\_bucket\_name) | S3 bucket (externally created) for storing load balancer access logs. Required if alb\_logging\_enabled is true. | `string` | `""` | no |
| <a name="input_alb_log_location_prefix"></a> [alb\_log\_location\_prefix](#input\_alb\_log\_location\_prefix) | S3 prefix within the log\_bucket\_name under which logs are stored. | `string` | `""` | no |
Expand Down Expand Up @@ -334,7 +336,8 @@ allow_github_webhooks = true
| <a name="input_container_memory"></a> [container\_memory](#input\_container\_memory) | The amount (in MiB) of memory used by the atlantis container. If not specified ecs\_task\_memory will be used | `number` | `null` | no |
| <a name="input_container_memory_reservation"></a> [container\_memory\_reservation](#input\_container\_memory\_reservation) | The amount of memory (in MiB) to reserve for the container | `number` | `128` | no |
| <a name="input_create_ecs_cluster"></a> [create\_ecs\_cluster](#input\_create\_ecs\_cluster) | Whether to create an ECS cluster or not | `bool` | `true` | no |
| <a name="input_create_route53_record"></a> [create\_route53\_record](#input\_create\_route53\_record) | Whether to create Route53 record for Atlantis | `bool` | `true` | no |
| <a name="input_create_route53_aaaa_record"></a> [create\_route53\_aaaa\_record](#input\_create\_route53\_aaaa\_record) | Whether to create Route53 AAAA record for Atlantis | `bool` | `false` | no |
| <a name="input_create_route53_record"></a> [create\_route53\_record](#input\_create\_route53\_record) | Whether to create Route53 A record for Atlantis | `bool` | `true` | no |
| <a name="input_custom_container_definitions"></a> [custom\_container\_definitions](#input\_custom\_container\_definitions) | A list of valid container definitions provided as a single valid JSON document. By default, the standard container definition is used. | `string` | `""` | no |
| <a name="input_custom_environment_secrets"></a> [custom\_environment\_secrets](#input\_custom\_environment\_secrets) | List of additional secrets the container will use (list should contain maps with `name` and `valueFrom`) | <pre>list(object(<br> {<br> name = string<br> valueFrom = string<br> }<br> ))</pre> | `[]` | no |
| <a name="input_custom_environment_variables"></a> [custom\_environment\_variables](#input\_custom\_environment\_variables) | List of additional environment variables the container will use (list should contain maps with `name` and `value`) | <pre>list(object(<br> {<br> name = string<br> value = string<br> }<br> ))</pre> | `[]` | no |
Expand Down
20 changes: 18 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ data "aws_partition" "current" {}
data "aws_region" "current" {}

data "aws_route53_zone" "this" {
count = var.create_route53_record ? 1 : 0
count = var.create_route53_record || var.create_route53_aaaa_record ? 1 : 0

name = var.route53_zone_name
private_zone = var.route53_private_zone
Expand Down Expand Up @@ -234,6 +234,8 @@ module "alb" {
prefix = var.alb_log_location_prefix
}

ip_address_type = var.alb_ip_address_type

enable_deletion_protection = var.alb_enable_deletion_protection

drop_invalid_header_fields = var.alb_drop_invalid_header_fields
Expand Down Expand Up @@ -405,7 +407,7 @@ module "acm" {
}

################################################################################
# Route53 record
# Route53 records
################################################################################
resource "aws_route53_record" "atlantis" {
count = var.create_route53_record ? 1 : 0
Expand All @@ -421,6 +423,20 @@ resource "aws_route53_record" "atlantis" {
}
}

resource "aws_route53_record" "atlantis_aaaa" {
count = var.create_route53_aaaa_record ? 1 : 0

zone_id = data.aws_route53_zone.this[0].zone_id
name = var.route53_record_name != null ? var.route53_record_name : var.name
type = "AAAA"

alias {
name = module.alb.lb_dns_name
zone_id = module.alb.lb_zone_id
evaluate_target_health = true
}
}

################################################################################
# EFS
################################################################################
Expand Down
14 changes: 13 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ variable "route53_private_zone" {
}

variable "create_route53_record" {
description = "Whether to create Route53 record for Atlantis"
description = "Whether to create Route53 A record for Atlantis"
type = bool
default = true
}
Expand Down Expand Up @@ -688,3 +688,15 @@ variable "ephemeral_storage_size" {
error_message = "The minimum supported value is 21 GiB and the maximum supported value is 200 GiB."
}
}

variable "alb_ip_address_type" {
description = "The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4 and dualstack"
type = string
default = "ipv4"
}

variable "create_route53_aaaa_record" {
description = "Whether to create Route53 AAAA record for Atlantis"
type = bool
default = false
}

0 comments on commit 6cefda0

Please sign in to comment.