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

Use tfedit to stop directly using deprecated S3 resources #688

Merged
merged 1 commit into from
Oct 25, 2022
Merged
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
107 changes: 76 additions & 31 deletions terraform-iac/modules/app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,48 @@ EOF

resource "aws_s3_bucket" "my_s3_bucket_logs" {
bucket = "${local.name}-${var.env}-logs"
}

resource "aws_s3_bucket_acl" "my_s3_bucket_logs" {
bucket = aws_s3_bucket.my_s3_bucket_logs.id
acl = "log-delivery-write"
lifecycle_rule {
id = "AutoAbortFailedMultipartUpload"
enabled = true
abort_incomplete_multipart_upload_days = 10
}

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

rule {
id = "AutoAbortFailedMultipartUpload"
status = "Enabled"

filter {
prefix = ""
}

abort_incomplete_multipart_upload {
days_after_initiation = 10
}
}
lifecycle_rule {
id = "ExpireOldLogs"
enabled = true

rule {
id = "ExpireOldLogs"
expiration {
days = var.log_retention_days
}
status = "Enabled"

filter {
prefix = ""
}
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}

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

rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
Expand All @@ -164,30 +188,51 @@ resource "aws_s3_bucket_public_access_block" "default_logs" {

resource "aws_s3_bucket" "my_s3_bucket" {
bucket = "${local.name}-${var.env}"
logging {
target_bucket = aws_s3_bucket.my_s3_bucket_logs.id
target_prefix = "log/"
}
versioning {
enabled = true
}
// lifecycle {
// prevent_destroy = true
// }
lifecycle_rule {
id = "AutoAbortFailedMultipartUpload"
enabled = true
abort_incomplete_multipart_upload_days = 10
}

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

rule {
id = "AutoAbortFailedMultipartUpload"
status = "Enabled"

filter {
prefix = ""
}

abort_incomplete_multipart_upload {
days_after_initiation = 10
}
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}

resource "aws_s3_bucket_logging" "my_s3_bucket" {
bucket = aws_s3_bucket.my_s3_bucket.id

target_bucket = aws_s3_bucket.my_s3_bucket_logs.id
target_prefix = "log/"
}

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

rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}

resource "aws_s3_bucket_versioning" "my_s3_bucket" {
bucket = aws_s3_bucket.my_s3_bucket.id

versioning_configuration {
status = "Enabled"
}
}


resource "aws_s3_bucket_public_access_block" "default" {
bucket = aws_s3_bucket.my_s3_bucket.id
block_public_acls = true
Expand Down