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

Fix s3 third party provider error on creating bucket without object lock #26317

Conversation

cristiGuranIonos
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Problem description

Error when trying to create bucket without lock configuration on 3rd party provider:

"error ObjectLockConfigurationNotFound: Object Lock configuration does not exist for this bucket"

Cause:

S3 provider returns ObjectLockConfigurationNotFound instead of ObjectLockConfigurationNotFoundError, so the strict check ErrCodeEquals in bucket.go does not work.

Also, the check if it's an aws region(partition) below returns true, because the region even though it's not aws has the same format eg: eu-west-2 and the regex check in the terraform-aws-provider is satisfied.

Output from acceptance testing:

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/s3/... -v -count 1 -parallel 20 -run='TestAccS3BucketObjectLockConfiguration*'  -timeout 180m
=== RUN   TestAccS3BucketObjectLockConfiguration_basic
=== PAUSE TestAccS3BucketObjectLockConfiguration_basic
=== RUN   TestAccS3BucketObjectLockConfiguration_disappears
=== PAUSE TestAccS3BucketObjectLockConfiguration_disappears
=== RUN   TestAccS3BucketObjectLockConfiguration_update
=== PAUSE TestAccS3BucketObjectLockConfiguration_update
=== RUN   TestAccS3BucketObjectLockConfiguration_migrate_noChange
=== PAUSE TestAccS3BucketObjectLockConfiguration_migrate_noChange
=== RUN   TestAccS3BucketObjectLockConfiguration_migrate_withChange
=== PAUSE TestAccS3BucketObjectLockConfiguration_migrate_withChange
=== CONT  TestAccS3BucketObjectLockConfiguration_basic
=== CONT  TestAccS3BucketObjectLockConfiguration_migrate_noChange
=== CONT  TestAccS3BucketObjectLockConfiguration_update
=== CONT  TestAccS3BucketObjectLockConfiguration_migrate_withChange
=== CONT  TestAccS3BucketObjectLockConfiguration_disappears
--- PASS: TestAccS3BucketObjectLockConfiguration_disappears (34.94s)
--- PASS: TestAccS3BucketObjectLockConfiguration_basic (38.44s)
--- PASS: TestAccS3BucketObjectLockConfiguration_migrate_withChange (57.96s)
--- PASS: TestAccS3BucketObjectLockConfiguration_migrate_noChange (59.55s)
--- PASS: TestAccS3BucketObjectLockConfiguration_update (63.63s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/s3 63.738s

:~/surse/terraform-provider-aws$ make testacc TESTS=TestAccS3Bucket_Basic_forceDestroyWithObjectLockEnabled PKG=s3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/s3/... -v -count 1 -parallel 20 -run='TestAccS3Bucket_Basic_forceDestroyWithObjectLockEnabled'  -timeout 180m
=== RUN   TestAccS3Bucket_Basic_forceDestroyWithObjectLockEnabled
=== PAUSE TestAccS3Bucket_Basic_forceDestroyWithObjectLockEnabled
=== CONT  TestAccS3Bucket_Basic_forceDestroyWithObjectLockEnabled
--- PASS: TestAccS3Bucket_Basic_forceDestroyWithObjectLockEnabled (38.77s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/s3 38.849s

make testacc TESTS=TestAccS3Bucket_Basic_basic PKG=s3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/s3/... -v -count 1 -parallel 20 -run='TestAccS3Bucket_Basic_basic'  -timeout 180m
=== RUN   TestAccS3Bucket_Basic_basic
=== PAUSE TestAccS3Bucket_Basic_basic
=== CONT  TestAccS3Bucket_Basic_basic
--- PASS: TestAccS3Bucket_Basic_basic (38.21s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/s3 38.292s

...

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/s3 Issues and PRs that pertain to the s3 service. sweeper Pertains to changes to or issues with the sweeper. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XS Managed by automation to categorize the size of a PR. labels Aug 16, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @cristiGuranIonos 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 17, 2022
@cristiGuranIonos
Copy link
Contributor Author

Added enhancement changelog to the PR. Thanks for taking a look!

@cristiGuranIonos
Copy link
Contributor Author

@justinretzolk Would there be anything else to add to the PR?

@justinretzolk
Copy link
Member

Hey @cristiGuranIonos 👋 Thank you for your contribution, and for checking in! On a quick glance, everything seems to be in order. At this point, we'll just need to wait for this PR to be prioritized, at which point one of the maintainers will do a full review before merging.

@martinwieczorekionos
Copy link

👍

@cristiGuranIonos
Copy link
Contributor Author

Any updates? Thanks!

@ewbankkit ewbankkit self-assigned this Apr 14, 2023
@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Apr 14, 2023
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccS3BucketObjectLockConfiguration_\|TestAccS3Bucket_Manage_objectLock' PKG=s3 ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/s3/... -v -count 1 -parallel 3  -run=TestAccS3BucketObjectLockConfiguration_\|TestAccS3Bucket_Manage_objectLock -timeout 180m
=== RUN   TestAccS3BucketObjectLockConfiguration_basic
=== PAUSE TestAccS3BucketObjectLockConfiguration_basic
=== RUN   TestAccS3BucketObjectLockConfiguration_disappears
=== PAUSE TestAccS3BucketObjectLockConfiguration_disappears
=== RUN   TestAccS3BucketObjectLockConfiguration_update
=== PAUSE TestAccS3BucketObjectLockConfiguration_update
=== RUN   TestAccS3BucketObjectLockConfiguration_migrate_noChange
=== PAUSE TestAccS3BucketObjectLockConfiguration_migrate_noChange
=== RUN   TestAccS3BucketObjectLockConfiguration_migrate_withChange
=== PAUSE TestAccS3BucketObjectLockConfiguration_migrate_withChange
=== RUN   TestAccS3BucketObjectLockConfiguration_noRule
=== PAUSE TestAccS3BucketObjectLockConfiguration_noRule
=== RUN   TestAccS3Bucket_Manage_objectLock
=== PAUSE TestAccS3Bucket_Manage_objectLock
=== RUN   TestAccS3Bucket_Manage_objectLock_deprecatedEnabled
=== PAUSE TestAccS3Bucket_Manage_objectLock_deprecatedEnabled
=== RUN   TestAccS3Bucket_Manage_objectLock_migrate
=== PAUSE TestAccS3Bucket_Manage_objectLock_migrate
=== RUN   TestAccS3Bucket_Manage_objectLockWithVersioning
=== PAUSE TestAccS3Bucket_Manage_objectLockWithVersioning
=== RUN   TestAccS3Bucket_Manage_objectLockWithVersioning_deprecatedEnabled
=== PAUSE TestAccS3Bucket_Manage_objectLockWithVersioning_deprecatedEnabled
=== CONT  TestAccS3BucketObjectLockConfiguration_basic
=== CONT  TestAccS3Bucket_Manage_objectLock
=== CONT  TestAccS3BucketObjectLockConfiguration_update
--- PASS: TestAccS3BucketObjectLockConfiguration_basic (25.43s)
=== CONT  TestAccS3BucketObjectLockConfiguration_migrate_noChange
--- PASS: TestAccS3BucketObjectLockConfiguration_update (40.01s)
=== CONT  TestAccS3BucketObjectLockConfiguration_noRule
--- PASS: TestAccS3Bucket_Manage_objectLock (42.00s)
=== CONT  TestAccS3BucketObjectLockConfiguration_migrate_withChange
--- PASS: TestAccS3BucketObjectLockConfiguration_migrate_noChange (34.23s)
=== CONT  TestAccS3BucketObjectLockConfiguration_disappears
--- PASS: TestAccS3BucketObjectLockConfiguration_noRule (22.75s)
=== CONT  TestAccS3Bucket_Manage_objectLockWithVersioning
--- PASS: TestAccS3BucketObjectLockConfiguration_migrate_withChange (34.48s)
=== CONT  TestAccS3Bucket_Manage_objectLockWithVersioning_deprecatedEnabled
--- PASS: TestAccS3BucketObjectLockConfiguration_disappears (20.30s)
=== CONT  TestAccS3Bucket_Manage_objectLock_migrate
--- PASS: TestAccS3Bucket_Manage_objectLockWithVersioning (26.35s)
=== CONT  TestAccS3Bucket_Manage_objectLock_deprecatedEnabled
--- PASS: TestAccS3Bucket_Manage_objectLockWithVersioning_deprecatedEnabled (28.60s)
--- PASS: TestAccS3Bucket_Manage_objectLock_migrate (30.69s)
--- PASS: TestAccS3Bucket_Manage_objectLock_deprecatedEnabled (24.91s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/s3	119.538s

@ewbankkit
Copy link
Contributor

@cristiGuranIonos Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit cb58bc0 into hashicorp:main Apr 14, 2023
@github-actions github-actions bot added this to the v4.64.0 milestone Apr 14, 2023
@github-actions
Copy link

This functionality has been released in v4.64.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/s3 Issues and PRs that pertain to the s3 service. size/L Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants