Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade AWS provider to a new major release #51

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions examples/basic/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 34 additions & 14 deletions modules/storage/main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
resource "aws_s3_bucket" "storage" {
bucket = var.bucket_name
acl = "private"
policy = data.aws_iam_policy_document.storage_bucket.json
}

// Encrypt with an Amazon-managed key
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_s3_bucket_acl" "storage" {
bucket = aws_s3_bucket.storage.id
acl = "private"
}

lifecycle_rule {
enabled = true
abort_incomplete_multipart_upload_days = 7
}
resource "aws_s3_bucket_cors_configuration" "storage" {
bucket = aws_s3_bucket.storage.id

cors_rule {
allowed_headers = ["*"]
Expand Down Expand Up @@ -61,6 +54,33 @@ resource "aws_s3_bucket" "storage" {
}
}

resource "aws_s3_bucket_lifecycle_configuration" "storage" {
bucket = aws_s3_bucket.storage.id

rule {
id = "abort-incomplete-multipart-upload"
status = "Enabled"
abort_incomplete_multipart_upload {
days_after_initiation = 7
}
}
}

resource "aws_s3_bucket_server_side_encryption_configuration" "storage" {
bucket = aws_s3_bucket.storage.id

// Encrypt with an Amazon-managed key
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}

resource "aws_s3_bucket_policy" "storage" {
bucket = aws_s3_bucket.storage.id
policy = data.aws_iam_policy_document.storage_bucket.json
}

data "aws_iam_policy_document" "storage_bucket" {
statement {
Expand Down
3 changes: 3 additions & 0 deletions modules/storage/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
# 4.9 includes backwards-compatible aws_s3_bucket syntax,
# which makes globally upgrading the aws provider easier
version = ">= 4.9.0"
}
}
}