Skip to content

Commit 173b8fc

Browse files
Update main.tf
Remove the `object_lock_enabled` attribute from the `aws_s3_bucket` resource, as it will force the creation of a new bucket and cannot be applied to an existing bucket. To enable object lock, using the `aws_s3_bucket_object_lock_configuration` resource alone is sufficient.
1 parent e1fb51b commit 173b8fc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ resource "aws_s3_bucket" "this" {
3131
bucket_prefix = var.bucket_prefix
3232

3333
force_destroy = var.force_destroy
34-
object_lock_enabled = var.object_lock_enabled
3534
tags = var.tags
3635
}
3736

@@ -391,6 +390,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "this" {
391390
resource "aws_s3_bucket_object_lock_configuration" "this" {
392391
count = local.create_bucket && var.object_lock_enabled && try(var.object_lock_configuration.rule.default_retention, null) != null ? 1 : 0
393392

393+
# Must have bucket versionign enabled first
394+
depends_on = [aws_s3_bucket_versioning.this]
394395
region = var.region
395396

396397
bucket = aws_s3_bucket.this[0].id

0 commit comments

Comments
 (0)