Skip to content

Commit

Permalink
Add a flag to control the ALIAS/CNAME switch
Browse files Browse the repository at this point in the history
We need to work around hashicorp/terraform#12570

JIRA: PLAT-1117
  • Loading branch information
grahamlyons committed Oct 3, 2017
1 parent 606ac35 commit acbd920
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ output "rendered" {
}

resource "aws_route53_record" "dns_record" {
count = "${var.alb_zone_id == "" ? 1 : 0}"
count = "${1 - var.alias}"

zone_id = "${data.aws_route53_zone.dns_domain.zone_id}"
name = "${var.env == "live" ? "${var.name}" : "${var.env}-${var.name}"}.${data.template_file.domain.rendered}"
Expand All @@ -26,7 +26,7 @@ resource "aws_route53_record" "dns_record" {
}

resource "aws_route53_record" "alb_alias" {
count = "${var.alb_zone_id == "" ? 0 : 1}"
count = "${var.alias}"

zone_id = "${data.aws_route53_zone.dns_domain.zone_id}"
name = "${var.env == "live" ? "${var.name}" : "${var.env}-${var.name}"}.${data.template_file.domain.rendered}"
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ variable "ttl" {
default = 60
}

variable "alias" {
description = "Create an alias rather than a CNAME"
default = "0"
}

variable "alb_zone_id" {
description = "The Route53 zone id of the ALB to create an alias for"
default = ""
Expand Down

0 comments on commit acbd920

Please sign in to comment.