Skip to content

Commit

Permalink
Upgrade AWS provider to 4.67
Browse files Browse the repository at this point in the history
Problem: we would like to use the latest version from AWS provider, but
there were attributes changes during the years

Solution: upgrade AWS provider to the latest 4.xx and adjust resources
  • Loading branch information
karandit committed Sep 29, 2023
1 parent 4ad8eb0 commit 1b79b68
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
39 changes: 21 additions & 18 deletions deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ variable "root_domain_name" {
resource "aws_s3_bucket" "www" {
// Our bucket's name is going to be the same as our site's domain name.
bucket = "${var.root_domain_name}-prod"
// We also need to create a policy that allows anyone to view the content.
// This is basically duplicating what we did in the ACL but it's required by
// AWS. This post: http://amzn.to/2Fa04ul explains why.
policy = <<POLICY
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::${var.root_domain_name}-prod/*"]
}
]
}
POLICY

}

resource "aws_s3_bucket_acl" "example" {
Expand Down Expand Up @@ -70,6 +52,27 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "www" {
}
}

resource "aws_s3_bucket_policy" "www_allow_access" {
bucket = aws_s3_bucket.www.id
// We also need to create a policy that allows anyone to view the content.
// This is basically duplicating what we did in the ACL but it's required by
// AWS. This post: http://amzn.to/2Fa04ul explains why.
policy = <<POLICY
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::${var.root_domain_name}-prod/*"]
}
]
}
POLICY
}

resource "aws_acm_certificate" "cert" {
domain_name = var.root_domain_name
validation_method = "DNS"
Expand Down
2 changes: 1 addition & 1 deletion deployment/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "= 3.76.0"
version = "= 4.67.0"
}
}
}

0 comments on commit 1b79b68

Please sign in to comment.