Skip to content

Commit 03ffdd0

Browse files
committed
Set DNS ALIAS instead of CNAME.
Use terraform-aws-route53-alias instead of terraform-aws-route53-cluster-hostname in order to create a Route53 ALIAS instead of a CNAME. Closes GH#134
1 parent 85fdbb4 commit 03ffdd0

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ Available targets:
232232
| deployment\_ignore\_health\_check | Do not cancel a deployment due to failed health checks | `bool` | `false` | no |
233233
| deployment\_timeout | Number of seconds to wait for an instance to complete executing commands | `number` | `600` | no |
234234
| description | Short description of the Environment | `string` | `""` | no |
235-
| dns\_subdomain | The subdomain to create on Route53 for the EB environment. For the subdomain to be created, the `dns_zone_id` variable must be set as well | `string` | `""` | no |
236-
| dns\_zone\_id | Route53 parent zone ID. The module will create sub-domain DNS record in the parent zone for the EB environment | `string` | `""` | no |
235+
| dns\_subdomain | The subdomain to create on Route53 for the EB environment. For the subdomain ALIAS record to be created, the `dns_zone_id` variable must be set as well | `string` | `""` | no |
236+
| dns\_zone\_id | Route53 parent zone ID. The module will create sub-domain DNS ALIAS record in the parent zone for the EB environment | `string` | `""` | no |
237237
| elastic\_beanstalk\_application\_name | Elastic Beanstalk application name | `string` | n/a | yes |
238238
| elb\_scheme | Specify `internal` if you want to create an internal load balancer in your Amazon VPC so that your Elastic Beanstalk application cannot be accessed from outside your Amazon VPC | `string` | `"public"` | no |
239239
| enable\_log\_publication\_control | Copy the log files for your application's Amazon EC2 instances to the Amazon S3 bucket associated with your application | `bool` | `false` | no |
@@ -254,6 +254,7 @@ Available targets:
254254
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
255255
| instance\_refresh\_enabled | Enable weekly instance replacement. | `bool` | `true` | no |
256256
| instance\_type | Instances type | `string` | `"t2.micro"` | no |
257+
| ipv6\_enabled | Set to true to enable an AAAA DNS record to be set as well as the A record | `bool` | `false` | no |
257258
| keypair | Name of SSH key that will be deployed on Elastic Beanstalk and DataPipeline instance. The key should be present in AWS | `string` | `""` | no |
258259
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
259260
| loadbalancer\_certificate\_arn | Load Balancer SSL certificate ARN. The certificate must be present in AWS Certificate Manager | `string` | `""` | no |

main.tf

+10-6
Original file line numberDiff line numberDiff line change
@@ -930,12 +930,16 @@ resource "aws_s3_bucket" "elb_logs" {
930930
}
931931

932932
module "dns_hostname" {
933-
source = "cloudposse/route53-cluster-hostname/aws"
934-
version = "0.10.0"
935-
enabled = var.dns_zone_id != "" && var.tier == "WebServer" ? true : false
936-
dns_name = var.dns_subdomain != "" ? var.dns_subdomain : module.this.name
937-
zone_id = var.dns_zone_id
938-
records = [aws_elastic_beanstalk_environment.default.cname]
933+
source = "cloudposse/route53-alias/aws"
934+
version = "0.10.0"
935+
enabled = var.dns_zone_id != "" && var.tier == "WebServer" ? true : false
936+
aliases = var.dns_subdomain != "" ? [var.dns_subdomain] : [var.name]
937+
evaluate_target_health = true
938+
ipv6_enabled = var.ipv6_enabled
939+
parent_zone_id = var.dns_zone_id
940+
target_dns_name = aws_elastic_beanstalk_environment.default.cname
941+
target_zone_id = var.alb_zone_id[var.region]
939942

940943
context = module.this.context
941944
}
945+

outputs.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
output "hostname" {
2-
value = module.dns_hostname.hostname
2+
value = module.dns_hostname.hostnames[0]
33
description = "DNS hostname"
44
}
55

variables.tf

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,19 @@ variable "loadbalancer_crosszone" {
3535
variable "dns_zone_id" {
3636
type = string
3737
default = ""
38-
description = "Route53 parent zone ID. The module will create sub-domain DNS record in the parent zone for the EB environment"
38+
description = "Route53 parent zone ID. The module will create sub-domain DNS ALIAS record in the parent zone for the EB environment"
3939
}
4040

4141
variable "dns_subdomain" {
4242
type = string
4343
default = ""
44-
description = "The subdomain to create on Route53 for the EB environment. For the subdomain to be created, the `dns_zone_id` variable must be set as well"
44+
description = "The subdomain to create on Route53 for the EB environment. For the subdomain ALIAS record to be created, the `dns_zone_id` variable must be set as well"
45+
}
46+
47+
variable "ipv6_enabled" {
48+
type = bool
49+
default = false
50+
description = "Set to true to enable an AAAA DNS record to be set as well as the A record"
4551
}
4652

4753
variable "allowed_security_groups" {

0 commit comments

Comments
 (0)