Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Commit

Permalink
Update modules called in root main.tf to support AWS provider version…
Browse files Browse the repository at this point in the history
… 3.x syntax (#43)

* Update code to use latest syntax

* Remove deprecated syntax

* Use conditional for each

* Remove wildcard from validation

* Remove deprecated syntax

* Skip over non wildcard domain with filtering
  • Loading branch information
ahinh43 authored Oct 28, 2021
1 parent 15ec10e commit 085e242
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
5 changes: 3 additions & 2 deletions autoscaling/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ resource "aws_alb_listener_rule" "applications" {
}

condition {
field = "host-header"
values = ["${var.application_name}.${var.base.domain_name}"]
host_header {
values = ["${var.application_name}.${var.base.domain_name}"]
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions fargate_cluster/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ resource "aws_alb_listener_rule" "applications" {
}

condition {
field = "host-header"
values = ["${var.application_name}.${var.base.domain_name}"]
host_header {
values = ["${var.application_name}.${var.base.domain_name}"]
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions ingress/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ resource "aws_alb_listener" "applications" {
redirect {
port = "443"
protocol = "HTTPS"
host = "${var.domain_name}"
host = var.domain_name
status_code = "HTTP_302"
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ resource "aws_security_group_rule" "lb_ingress" {
protocol = "tcp"

# If fronted by nginx, only accept traffic from inside the VPC
cidr_blocks = var.public ? ["0.0.0.0/0"] : ["${var.cidr_block}"]
cidr_blocks = var.public ? ["0.0.0.0/0"] : [var.cidr_block]

security_group_id = aws_security_group.alb.id
}
Expand Down
5 changes: 3 additions & 2 deletions instance/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ resource "aws_alb_listener_rule" "applications" {
}

condition {
field = "host-header"
values = ["${var.application_name}.${var.base.domain_name}"]
host_header {
values = ["${var.application_name}.${var.base.domain_name}"]
}
}
}

Expand Down
18 changes: 13 additions & 5 deletions wildcard_cert/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,24 @@ resource "aws_acm_certificate" "domain" {
resource "aws_acm_certificate_validation" "domain" {
count = var.primary ? 1 : 0
certificate_arn = aws_acm_certificate.domain[0].arn
validation_record_fqdns = aws_route53_record.validation[*].fqdn
validation_record_fqdns = [for record in aws_route53_record.validation : record.fqdn]
}

# Only need to validate the first record because the wildcard entry will use the same DNS record
resource "aws_route53_record" "validation" {
count = var.primary ? 1 : 0
name = aws_acm_certificate.domain[0].domain_validation_options[0]["resource_record_name"]
type = aws_acm_certificate.domain[0].domain_validation_options[0]["resource_record_type"]
for_each = var.primary ? {
for dvo in aws_acm_certificate.domain[0].domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
}
# Skips the domain if it doesn't contain a wildcard
if length(regexall("\\*\\..+", dvo.domain_name)) > 0
} : {}
name = each.value.name
type = each.value.type
zone_id = data.aws_route53_zone.external.id
records = [aws_acm_certificate.domain[0].domain_validation_options[0]["resource_record_value"]]
records = [each.value.record]
ttl = 60
}

0 comments on commit 085e242

Please sign in to comment.