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

Removed deprecated argument object_lock_enabled in aws_s3_bucket #144

Closed
wants to merge 2 commits into from

Conversation

imran-init
Copy link

…bucket in resource aws_s3_bucket_object_lock_configuration.default

what

  • Removed deprecated argument object_lock_enabled from aws_s3_bucket.default. object_lock_enabled is enabled for this bucket in resource aws_s3_bucket_object_lock_configuration.default

why

  • object_lock_enabled has been deprecated in the bucket resource.

references

…bucket in resource aws_s3_bucket_object_lock_configuration.default
@imran-init imran-init requested review from a team as code owners April 14, 2022 13:37
Copy link

@bridgecrew bridgecrew bot left a comment

Choose a reason for hiding this comment

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

Bridgecrew has found infrastructure configuration errors in this PR ⬇️

main.tf Show resolved Hide resolved
@osterman
Copy link
Member

In the current docs, it does not show as deprecated

@imran-init
Copy link
Author

Thanks for the review. Here is from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket

NOTE on S3 Bucket Object Lock Configuration:

S3 Bucket Object Lock can be configured in either the standalone resource [aws_s3_bucket_object_lock_configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) or with the deprecated parameter object_lock_configuration in the resource aws_s3_bucket. Configuring with both will cause inconsistencies and may overwrite configuration.

}
}


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.

Dependent Resources



Calculating...

Copy link

@bridgecrew bridgecrew bot left a comment

Choose a reason for hiding this comment

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

⚠️   Due to 7d47803 - updated git config to resolve auto-format/preivilleged checout. - 1 new error was added

Change details

Error ID Change Path Resource
BC_AWS_NETWORKING_52 Added /main.tf aws_s3_bucket.default

@nitrocode nitrocode added the patch A minor, backward compatible change label Apr 15, 2022
@nitrocode
Copy link
Member

/test all

@nitrocode
Copy link
Member

@imran-init makes sense to me. Nice catch!

@nitrocode
Copy link
Member

nitrocode commented Apr 15, 2022

Hmm unfortunately without this, we run into this error

TestExamplesCompleteWithObjectLock 2022-04-15T00:41:18Z logger.go:66: │ Error: error creating S3 bucket (eg-test-s3-object-lock-test-bfujfx) Object Lock configuration: InvalidBucketState: Object Lock configuration cannot be enabled on existing buckets

Have you been able to test this locally ?

@nitrocode
Copy link
Member

nitrocode commented Apr 15, 2022

Ah here is the full description

https://registry.terraform.io/providers/hashicorp%20%20/aws/latest/docs/resources/s3_bucket_object_lock_configuration

This resource does not enable Object Lock for new buckets. It configures a default retention period for objects placed in the specified bucket. Thus, to enable Object Lock for a new bucket, see the Using object lock configuration section in the aws_s3_bucket resource or the Object Lock configuration for a new bucket example below. If you want to enable Object Lock for an existing bucket, contact AWS Support and see the Object Lock configuration for an existing bucket example below.

References:

It sounds like the deprecation notice is wrong in the hashicorp/aws provider to be honest so I'm going to close this PR for now until there is a strong reason to bring this back.

@nitrocode nitrocode closed this Apr 15, 2022
@nitrocode nitrocode changed the title Removed deprecated argument. object_lock_enabled is enabled for this … Removed deprecated argument object_lock_enabled in aws_s3_bucket Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants