Skip to content

Commit

Permalink
Merge pull request #1 from DNXLabs/terraform-0.12-support
Browse files Browse the repository at this point in the history
Adds terraform 0.12 support
  • Loading branch information
arthurbdiniz authored Mar 9, 2020
2 parents 600f7a5 + 0dcb293 commit e9dfeb6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion _data.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
data "aws_s3_bucket" "selected" {
bucket = "${var.s3_bucket_id}"
bucket = var.s3_bucket_id
}
2 changes: 1 addition & 1 deletion _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable "name" {}
variable "s3_bucket_id" {}

variable "hostnames" {
type = "list"
type = list(string)
}

variable "hosted_zone" {}
Expand Down
16 changes: 8 additions & 8 deletions cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ resource "aws_cloudfront_origin_access_identity" "default" {
resource "aws_cloudfront_distribution" "default" {
enabled = true
is_ipv6_enabled = true
comment = "${var.name}"
aliases = "${var.hostnames}"
comment = var.name
aliases = var.hostnames
price_class = "PriceClass_All"
default_root_object = "index.html"

origin {
domain_name = "${data.aws_s3_bucket.selected.bucket_regional_domain_name}"
domain_name = data.aws_s3_bucket.selected.bucket_regional_domain_name
origin_id = "s3Origin"

s3_origin_config {
origin_access_identity = "${aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path}"
origin_access_identity = aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path
}
}

dynamic "logging_config" {
for_each = "${compact([var.cloudfront_logging_bucket])}"
for_each = compact([var.cloudfront_logging_bucket])

content {
include_cookies = false
bucket = "${var.cloudfront_logging_bucket}"
prefix = "${var.cloudfront_logging_prefix}"
bucket = var.cloudfront_logging_bucket
prefix = var.cloudfront_logging_prefix
}
}

Expand All @@ -50,7 +50,7 @@ resource "aws_cloudfront_distribution" "default" {
}

viewer_certificate {
acm_certificate_arn = "${var.certificate_arn}"
acm_certificate_arn = var.certificate_arn
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1.1_2016"
}
Expand Down
10 changes: 5 additions & 5 deletions route53.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
data "aws_route53_zone" "selected" {
name = "${var.hosted_zone}"
name = var.hosted_zone
}

resource "aws_route53_record" "hostname" {
count = "${var.hostname_create ? length(var.hostnames) : 0}"
count = var.hostname_create ? length(var.hostnames) : 0

zone_id = "${data.aws_route53_zone.selected.zone_id}"
name = "${var.hostnames[count.index]}"
zone_id = data.aws_route53_zone.selected.zone_id
name = var.hostnames[count.index]
type = "CNAME"
ttl = "300"
records = ["${aws_cloudfront_distribution.default.domain_name}"]
records = [aws_cloudfront_distribution.default.domain_name]
}
10 changes: 5 additions & 5 deletions s3-policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ data "aws_iam_policy_document" "s3_policy" {

principals {
type = "AWS"
identifiers = ["${aws_cloudfront_origin_access_identity.default.iam_arn}"]
identifiers = [aws_cloudfront_origin_access_identity.default.iam_arn]
}
}

statement {
actions = ["s3:ListBucket"]
resources = ["${data.aws_s3_bucket.selected.arn}"]
resources = [data.aws_s3_bucket.selected.arn]

principals {
type = "AWS"
identifiers = ["${aws_cloudfront_origin_access_identity.default.iam_arn}"]
identifiers = [aws_cloudfront_origin_access_identity.default.iam_arn]
}
}
}

resource "aws_s3_bucket_policy" "oai" {
bucket = "${var.s3_bucket_id}"
policy = "${data.aws_iam_policy_document.s3_policy.json}"
bucket = var.s3_bucket_id
policy = data.aws_iam_policy_document.s3_policy.json
}

0 comments on commit e9dfeb6

Please sign in to comment.