Skip to content

Commit

Permalink
Upgrade aws provider to 3.76
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 some deprecated attributes

Solution: upgrade AWS provider to the latest 3.xx and adjust resources
  • Loading branch information
karandit committed Sep 29, 2023
1 parent b5a8e59 commit 4ad8eb0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
39 changes: 23 additions & 16 deletions deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +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"
// Because we want our site to be available on the internet, we set this so
// anyone can read this bucket.
acl = "public-read"
// 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.
Expand All @@ -45,20 +42,30 @@ resource "aws_s3_bucket" "www" {
}
POLICY

// S3 understands what it means to host a website.
website {
// Here we tell S3 what to use when a request comes in to the root
index_document = "index.html"
// The page to serve up if a request results in an error or a non-existing
// page.
//error_document = "404.html"
}

resource "aws_s3_bucket_acl" "example" {
bucket = aws_s3_bucket.www.id

// Because we want our site to be available on the internet, we set this so
// anyone can read this bucket.
acl = "public-read"
}

resource "aws_s3_bucket_website_configuration" "www" {
bucket = aws_s3_bucket.www.id

index_document {
suffix = "index.html"
}
}

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
resource "aws_s3_bucket_server_side_encryption_configuration" "www" {
bucket = aws_s3_bucket.www.id

rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
Expand Down Expand Up @@ -102,7 +109,7 @@ resource "aws_cloudfront_distribution" "www_distribution" {
}

// Here we're using our S3 bucket's URL!
domain_name = aws_s3_bucket.www.website_endpoint
domain_name = aws_s3_bucket_website_configuration.www.website_endpoint

// This can be any name to identify this origin.
origin_id = var.root_domain_name
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.27.0"
version = "= 3.76.0"
}
}
}

0 comments on commit 4ad8eb0

Please sign in to comment.