From 7a79788817f5808ef71fc922cb8e29820d530717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20J=C3=BAnior=20do=20Nascimento=20Lima?= Date: Thu, 2 Jun 2022 17:04:21 -0300 Subject: [PATCH] Remove deprecated template datasource --- site-main/main.tf | 87 +------------------ site-main/website_bucket_policy.json | 16 ---- ...i.json => website_bucket_policy_oai.tftpl} | 0 3 files changed, 2 insertions(+), 101 deletions(-) delete mode 100644 site-main/website_bucket_policy.json rename site-main/{website_bucket_policy_oai.json => website_bucket_policy_oai.tftpl} (100%) diff --git a/site-main/main.tf b/site-main/main.tf index 870a3fc..2f240b8 100644 --- a/site-main/main.tf +++ b/site-main/main.tf @@ -16,38 +16,6 @@ ## certificates must be requested in region us-east-1 ################################################################################################################ -#locals { -# tags = merge( -# var.tags, -# { -# "domain" = var.domain -# }, -# ) -#} - -################################################################################################################ -## Configure the bucket and static website hosting -################################################################################################################ - -data "template_file" "bucket_policy_oai" { - count = var.enable_oai == true ? 1 : 0 - template = file("${path.module}/website_bucket_policy_oai.json") - - vars = { - bucket = var.bucket_name - secret = var.duplicate-content-penalty-secret - iam_arn = aws_cloudfront_origin_access_identity.origin_access_identity[0].iam_arn - } -} - -data "template_file" "bucket_policy" { - template = file("${path.module}/website_bucket_policy.json") - - vars = { - bucket = var.bucket_name - secret = var.duplicate-content-penalty-secret - } -} locals { origin_domain_name = var.create_bucket == true ? aws_s3_bucket.website_bucket[0].website_endpoint : "${var.bucket_name}.s3.amazonaws.com" @@ -79,7 +47,8 @@ resource "aws_s3_bucket_acl" "website_bucket" { resource "aws_s3_bucket_policy" "website_bucket" { count = var.create_bucket == true ? 1 : 0 bucket = aws_s3_bucket.website_bucket[0].id - policy = var.enable_oai == true ? data.template_file.bucket_policy_oai[0].rendered : data.template_file.bucket_policy.rendered + # policy = data.template_file.bucket_policy_oai[0].rendered + policy = templatefile("${path.module}/website_bucket_policy_oai.tftpl", { iam_arn = aws_cloudfront_origin_access_identity.origin_access_identity[0].iam_arn, bucket = var.bucket_name }) } resource "aws_s3_bucket_website_configuration" "website_bucket" { @@ -284,55 +253,3 @@ resource "aws_cloudfront_origin_access_identity" "origin_access_identity" { count = var.enable_oai == true ? 1 : 0 comment = "Create OAI to use in CF: ${var.domain[0]}" } - -################################################################################################################ -## Cache Policy -################################################################################################################ - -# resource "aws_cloudfront_cache_policy" "main" { -# count = var.enable_cache_policy == true ? 1 : 0 -# -# name = "behavior-s3-cors-Cache" -# default_ttl = var.cache_policy_default_ttl -# max_ttl = var.cache_policy_max_ttl -# min_ttl = var.cache_policy_min_ttl -# -# parameters_in_cache_key_and_forwarded_to_origin { -# headers_config { -# header_behavior = "whitelist" -# headers { -# items = ["origin"] -# } -# } -# cookies_config { -# cookie_behavior = "none" -# } -# query_strings_config { -# query_string_behavior = "all" -# } -# } -# } - -################################################################################################################ -## Origin Request Policy -################################################################################################################ -# -# resource "aws_cloudfront_origin_request_policy" "main" { -# count = var.enable_cache_policy == true ? 1 : 0 -# -# name = "behavior-managed-cors-s3-origin" -# comment = "Policy for S3 origin with CORS" -# -# headers_config { -# header_behavior = "whitelist" -# headers { -# items = ["origin", "access-control-request-headers", "access-control-request-method"] -# } -# } -# cookies_config { -# cookie_behavior = "none" -# } -# query_strings_config { -# query_string_behavior = "none" -# } -# } diff --git a/site-main/website_bucket_policy.json b/site-main/website_bucket_policy.json deleted file mode 100644 index 3ba4933..0000000 --- a/site-main/website_bucket_policy.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "PublicReadAccess", - "Principal": { - "AWS": "*" - }, - "Effect": "Allow", - "Action": [ - "s3:GetObject" - ], - "Resource": "arn:aws:s3:::${bucket}/*" - } - ] -} \ No newline at end of file diff --git a/site-main/website_bucket_policy_oai.json b/site-main/website_bucket_policy_oai.tftpl similarity index 100% rename from site-main/website_bucket_policy_oai.json rename to site-main/website_bucket_policy_oai.tftpl