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 object lock enabled #148

Merged
merged 4 commits into from
May 6, 2022
Merged
Changes from 2 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
11 changes: 3 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
enabled = module.this.enabled
partition = join("", data.aws_partition.current.*.partition)

object_lock_enabled = local.enabled && var.object_lock_configuration != null
replication_enabled = local.enabled && var.s3_replication_enabled
versioning_enabled = local.enabled && var.versioning_enabled
transfer_acceleration_enabled = local.enabled && var.transfer_acceleration_enabled
Expand Down Expand Up @@ -38,13 +39,7 @@ resource "aws_s3_bucket" "default" {
bucket = local.bucket_name
force_destroy = var.force_destroy

dynamic "object_lock_configuration" {
for_each = var.object_lock_configuration != null ? [1] : []

content {
object_lock_enabled = "Enabled"
}
}
object_lock_enabled = local.object_lock_enabled
nitrocode marked this conversation as resolved.
Show resolved Hide resolved
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   Ensure S3 Bucket has public access blocks
    Resource: aws_s3_bucket.default | ID: BC_AWS_NETWORKING_52

How to Fix

resource "aws_s3_bucket" "bucket_good_1" {
  bucket = "bucket_good"
}

resource "aws_s3_bucket_public_access_block" "access_good_1" {
  bucket = aws_s3_bucket.bucket_good_1.id

  block_public_acls   = true
  block_public_policy = true
}

Description

When you create an S3 bucket, it is good practice to set the additional resource **aws_s3_bucket_public_access_block** to ensure the bucket is never accidentally public.

We recommend you ensure S3 bucket has public access blocks. If the public access block is not attached it defaults to False.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   Ensure S3 Bucket has public access blocks
    Resource: aws_s3_bucket.default | ID: BC_AWS_NETWORKING_52

How to Fix

resource "aws_s3_bucket" "bucket_good_1" {
  bucket = "bucket_good"
}

resource "aws_s3_bucket_public_access_block" "access_good_1" {
  bucket = aws_s3_bucket.bucket_good_1.id

  block_public_acls   = true
  block_public_policy = true
}

Description

When you create an S3 bucket, it is good practice to set the additional resource **aws_s3_bucket_public_access_block** to ensure the bucket is never accidentally public.

We recommend you ensure S3 bucket has public access blocks. If the public access block is not attached it defaults to False.


tags = module.this.tags
}
Expand Down Expand Up @@ -289,7 +284,7 @@ resource "aws_s3_bucket_replication_configuration" "default" {
}

resource "aws_s3_bucket_object_lock_configuration" "default" {
count = local.enabled && var.object_lock_configuration != null ? 1 : 0
count = local.object_lock_enabled ? 1 : 0

bucket = join("", aws_s3_bucket.default.*.id)

Expand Down