From 02e52fc7e2a45e965ce6e3a01bd4d550a9077296 Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Wed, 26 Apr 2023 11:58:07 +0800 Subject: [PATCH 1/4] remove deprecated S3 arguments --- main.tf | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/main.tf b/main.tf index 037e7dd..0be153f 100644 --- a/main.tf +++ b/main.tf @@ -12,18 +12,34 @@ data "template_file" "bucket_policy" { resource "aws_s3_bucket" "hugo" { bucket = var.bucket_name - acl = "public-read" - policy = data.template_file.bucket_policy.rendered force_destroy = true +} + +resource "aws_s3_bucket_acl" "hugo" { + bucket = aws_s3_bucket.hugo.id + acl = "public-read" +} - website { - index_document = var.index_document - error_document = "${var.origin_path}/${var.error_document}" +resource "aws_s3_bucket_policy" "hugo" { + bucket = aws_s3_bucket.hugo.id + policy = data.template_file.bucket_policy.rendered +} - // Routing rule is needed to support hugo friendly urls - routing_rules = var.routing_rules +resource "aws_s3_bucket_website_configuration" "hugo" { + bucket = aws_s3_bucket.hugo.id + index_document { + suffix = var.index_document } + error_document { + key = "${var.origin_path}/${var.error_document}" + } + + // Routing rule is needed to support hugo friendly urls + routing_rules = var.routing_rules +} +resource "aws_s3_bucket_cors_configuration" "hugo" { + bucket = aws_s3_bucket.hugo.id cors_rule { allowed_headers = var.cors_allowed_headers allowed_methods = var.cors_allowed_methods From 491c9dbb2c1f153bfd19ffdc198768a0a866d639 Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Wed, 26 Apr 2023 12:02:28 +0800 Subject: [PATCH 2/4] add a required_providers block --- versions.tf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/versions.tf b/versions.tf index ac97c6a..c329294 100644 --- a/versions.tf +++ b/versions.tf @@ -1,4 +1,11 @@ terraform { required_version = ">= 0.12" + + required_providers { + aws = { + version = ">= 3.0" + source = "hashicorp/aws" + } + } } From 1da194cdabd67d61e67cb063d646083a9b81c23c Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Wed, 26 Apr 2023 12:04:22 +0800 Subject: [PATCH 3/4] bump requirement to AWS provider version 4 --- versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.tf b/versions.tf index c329294..e1bd3ab 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { - version = ">= 3.0" + version = ">= 4.0" source = "hashicorp/aws" } } From e3dc1c9b8dc82465fab01688f3a1f4d83957ce45 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Mon, 15 May 2023 08:50:41 +0800 Subject: [PATCH 4/4] Constrain AWS provider to only use version 4.x Co-authored-by: forevermatt --- versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.tf b/versions.tf index e1bd3ab..7bc03de 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { - version = ">= 4.0" + version = ">= 4.0, < 5" source = "hashicorp/aws" } }