Skip to content

Commit

Permalink
Merge pull request #2 from trebidav/tf-upgrade
Browse files Browse the repository at this point in the history
upgrade to new >0.13 tf format
  • Loading branch information
trebidav authored Dec 6, 2022
2 parents 92b08e2 + 3368210 commit ed56465
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions acm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ resource "aws_acm_certificate" "cert" {
}

resource "aws_acm_certificate_validation" "validation" {
certificate_arn = "${aws_acm_certificate.cert.arn}"
validation_record_fqdns = ["${aws_route53_record.cert_validation_1.fqdn}", "${aws_route53_record.cert_validation_2.fqdn}"]
certificate_arn = aws_acm_certificate.cert.arn
validation_record_fqdns = [aws_route53_record.cert_validation_1.fqdn, aws_route53_record.cert_validation_2.fqdn]
}
10 changes: 5 additions & 5 deletions cloudfront.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "aws_cloudfront_distribution" "redirect" {
origin {
domain_name = "${aws_s3_bucket.redirect_bucket.bucket}.s3-website.${data.aws_region.current.name}.amazonaws.com"
origin_id = "${aws_s3_bucket.redirect_bucket.bucket}"
origin_id = aws_s3_bucket.redirect_bucket.bucket

custom_origin_config {
http_port = 80
Expand All @@ -12,7 +12,7 @@ resource "aws_cloudfront_distribution" "redirect" {
}

price_class = "PriceClass_100"
comment = "${aws_s3_bucket.redirect_bucket.bucket}"
comment = aws_s3_bucket.redirect_bucket.bucket
enabled = true
is_ipv6_enabled = false

Expand All @@ -27,7 +27,7 @@ resource "aws_cloudfront_distribution" "redirect" {
default_cache_behavior {
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "${aws_s3_bucket.redirect_bucket.bucket}"
target_origin_id = aws_s3_bucket.redirect_bucket.bucket
compress = true

min_ttl = 31536000
Expand All @@ -46,10 +46,10 @@ resource "aws_cloudfront_distribution" "redirect" {
}

viewer_certificate {
acm_certificate_arn = "${aws_acm_certificate.cert.arn}"
acm_certificate_arn = aws_acm_certificate.cert.arn
ssl_support_method = "sni-only"
}

wait_for_deployment = false
depends_on = ["aws_acm_certificate_validation.validation"]
depends_on = [aws_acm_certificate_validation.validation]
}
32 changes: 16 additions & 16 deletions route53.tf
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
data "aws_route53_zone" "zone" {
name = "${var.zone}"
name = var.zone
}

resource "aws_route53_record" "redirect-www" {
zone_id = "${data.aws_route53_zone.zone.zone_id}"
name = "${data.aws_route53_zone.zone.name}"
zone_id = data.aws_route53_zone.zone.zone_id
name = data.aws_route53_zone.zone.name
type = "A"

alias {
name = "${aws_cloudfront_distribution.redirect.domain_name}"
zone_id = "${aws_cloudfront_distribution.redirect.hosted_zone_id}"
name = aws_cloudfront_distribution.redirect.domain_name
zone_id = aws_cloudfront_distribution.redirect.hosted_zone_id
evaluate_target_health = false
}
}

resource "aws_route53_record" "redirect" {
zone_id = "${data.aws_route53_zone.zone.zone_id}"
zone_id = data.aws_route53_zone.zone.zone_id
name = "www.${data.aws_route53_zone.zone.name}"
type = "A"

alias {
name = "${aws_cloudfront_distribution.redirect.domain_name}"
zone_id = "${aws_cloudfront_distribution.redirect.hosted_zone_id}"
name = aws_cloudfront_distribution.redirect.domain_name
zone_id = aws_cloudfront_distribution.redirect.hosted_zone_id
evaluate_target_health = false
}
}

resource "aws_route53_record" "cert_validation_1" {
name = "${aws_acm_certificate.cert.domain_validation_options.0.resource_record_name}"
type = "${aws_acm_certificate.cert.domain_validation_options.0.resource_record_type}"
zone_id = "${data.aws_route53_zone.zone.zone_id}"
records = ["${aws_acm_certificate.cert.domain_validation_options.0.resource_record_value}"]
name = aws_acm_certificate.cert.domain_validation_options.0.resource_record_name
type = aws_acm_certificate.cert.domain_validation_options.0.resource_record_type
zone_id = data.aws_route53_zone.zone.zone_id
records = [aws_acm_certificate.cert.domain_validation_options.0.resource_record_value]
ttl = 60
}

resource "aws_route53_record" "cert_validation_2" {
name = "${aws_acm_certificate.cert.domain_validation_options.1.resource_record_name}"
type = "${aws_acm_certificate.cert.domain_validation_options.1.resource_record_type}"
zone_id = "${data.aws_route53_zone.zone.zone_id}"
records = ["${aws_acm_certificate.cert.domain_validation_options.1.resource_record_value}"]
name = aws_acm_certificate.cert.domain_validation_options.1.resource_record_name
type = aws_acm_certificate.cert.domain_validation_options.1.resource_record_type
zone_id = data.aws_route53_zone.zone.zone_id
records = [aws_acm_certificate.cert.domain_validation_options.1.resource_record_value]
ttl = 60
}
2 changes: 1 addition & 1 deletion s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ resource "aws_s3_bucket" "redirect_bucket" {
acl = "public-read"

website {
redirect_all_requests_to = "${var.target_url}"
redirect_all_requests_to = var.target_url
}
}
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
variable "zone" {
description = "Route53 zone name"
type = "string"
type = string
}

variable "target_url" {
description = "URL to redirect to"
type = "string"
type = string
}

0 comments on commit ed56465

Please sign in to comment.