-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
r/s3_bucket_replication_configuration: Add token parameter for x-amz-bucket-object-lock-token #23624
Conversation
This allows one to enable replication on an object-lock enabled bucket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome @alexb-dd 👋
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! 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alexb-dd , thank you for this PR! Overall it's looking great, just a couple comments to address and if you could please add the token
argument to the documentation (website/docs/r/s3_bucket_replication_configuration.html
) similar to the description provided in the aws_s3_bucket_object_lock_configuration
resource's token arg, then we should be good to go, e.g.
I'm curious, did AWS support first recommend enabling bucket versioning to then get the token that get's generated behind the scenes? (that's currently what is noted in the aws_s3_bucket_object_lock_configuration
docs)
They asked me for the bucket for which to generate the token. Thus the bucket needed to exist. I think since object lock being enabled on a bucket (whether at creation time or after the fact) implies versioning is on, they did not need to ask for versioning explicitly. |
1) Copied the existing implementation from bucket_object_lock_configuration.go which allowed us to make it sensitive, per below: + token = (sensitive value) 2) Fixed optional handling to not initialize token in constructor expression but only if it is set. 3) Added docs for new field.
@@ -216,6 +216,8 @@ The following arguments are supported: | |||
|
|||
* `bucket` - (Required) The name of the source S3 bucket you want Amazon S3 to monitor. | |||
* `role` - (Required) The ARN of the IAM role for Amazon S3 to assume when replicating the objects. | |||
* `token` - (Optional) A token to allow replication to be enabled on an Object Lock-enabled bucket. You must contact AWS support for the bucket's "Object Lock token". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor nit: do you mind moving token
just below rule
to maintain the order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to edit this as we're going to do a release today and would love to get this in as it's ready to go 🚀
Output of acceptance tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @alexb-dd , LGTM 🚀
This functionality has been released in v4.5.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! |
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. |
This allows one to enable replication on an object-lock enabled bucket, OR enabling object lock on an existing bucket. See https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock-managing.html#object-lock-managing-replication for details.
Community Note
Closes #14061.
Output from acceptance testing:
make test
passed, and tested this on an ad-hoc TF module and was able to successfully enable replication on an object-lock enabled bucket. Before:After: