Skip to content

Commit 538c633

Browse files
authored
Merge pull request #23624 from alexb-dd/f-replconfig-token
r/s3_bucket_replication_configuration: Add token parameter for x-amz-bucket-object-lock-token
2 parents 79a092a + beac59f commit 538c633

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.changelog/23624.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```release-note:enhancement
2+
resource/aws_s3_bucket_replication_configuration: Add `token` field to specify
3+
x-amz-bucket-object-lock-token for enabling replication on object lock enabled
4+
buckets or enabling object lock on an existing bucket.
5+
```

internal/service/s3/bucket_replication_configuration.go

+13
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ func ResourceBucketReplicationConfiguration() *schema.Resource {
3838
Required: true,
3939
ValidateFunc: verify.ValidARN,
4040
},
41+
"token": {
42+
Type: schema.TypeString,
43+
Optional: true,
44+
Sensitive: true,
45+
},
4146
"rule": {
4247
Type: schema.TypeSet,
4348
Required: true,
@@ -311,6 +316,10 @@ func resourceBucketReplicationConfigurationCreate(d *schema.ResourceData, meta i
311316
ReplicationConfiguration: rc,
312317
}
313318

319+
if v, ok := d.GetOk("token"); ok {
320+
input.Token = aws.String(v.(string))
321+
}
322+
314323
err := resource.Retry(propagationTimeout, func() *resource.RetryError {
315324
_, err := conn.PutBucketReplication(input)
316325
if tfawserr.ErrCodeEquals(err, s3.ErrCodeNoSuchBucket) || tfawserr.ErrMessageContains(err, "InvalidRequest", "Versioning must be 'Enabled' on the bucket") {
@@ -387,6 +396,10 @@ func resourceBucketReplicationConfigurationUpdate(d *schema.ResourceData, meta i
387396
ReplicationConfiguration: rc,
388397
}
389398

399+
if v, ok := d.GetOk("token"); ok {
400+
input.Token = aws.String(v.(string))
401+
}
402+
390403
err := resource.Retry(propagationTimeout, func() *resource.RetryError {
391404
_, err := conn.PutBucketReplication(input)
392405
if tfawserr.ErrCodeEquals(err, s3.ErrCodeNoSuchBucket) || tfawserr.ErrMessageContains(err, "InvalidRequest", "Versioning must be 'Enabled' on the bucket") {

website/docs/r/s3_bucket_replication_configuration.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ The following arguments are supported:
219219
* `bucket` - (Required) The name of the source S3 bucket you want Amazon S3 to monitor.
220220
* `role` - (Required) The ARN of the IAM role for Amazon S3 to assume when replicating the objects.
221221
* `rule` - (Required) Set of configuration blocks describing the rules managing the replication [documented below](#rule).
222+
* `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".
223+
For more details, see [Using S3 Object Lock with replication](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock-managing.html#object-lock-managing-replication).
222224

223225
### rule
224226

0 commit comments

Comments
 (0)