Skip to content

Commit

Permalink
fix: Choose one type of encryption for buckets (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
alldoami authored Mar 21, 2024
1 parent 5c650fc commit 125b37b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions aws-s3-private-bucket/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,6 @@ resource "aws_s3_bucket" "bucket" {
tags = local.tags
}

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

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

resource "aws_s3_bucket_public_access_block" "bucket" {
count = var.public_access_block ? 1 : 0

Expand Down Expand Up @@ -204,6 +194,18 @@ resource "aws_kms_key" "bucket_kms_key" {
}
}

resource "aws_s3_bucket_server_side_encryption_configuration" "bucket_sse_encryption" {
count = var.kms_encryption != null ? 0 : 1

bucket = aws_s3_bucket.bucket.id

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

resource "aws_s3_bucket_server_side_encryption_configuration" "bucket_kms_encryption" {
count = var.kms_encryption != null ? 1 : 0

Expand Down

0 comments on commit 125b37b

Please sign in to comment.