-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
versioning enabled = false leads to 'delete markers' #12354
Comments
I found The current implementation implicitly set the versioning configuration to It causes a problem when writing a generic module for s3/aws_s3_bucket.tf variable "bucket" {
type = string
}
variable "versioning" {
type = bool
}
resource "aws_s3_bucket" "test" {
bucket = var.bucket
acl = "private"
dynamic "versioning" {
for_each = try([coalesce(var.versioning)], [])
content {
enabled = versioning.value
}
}
} main.tf module "test" {
source = "./s3"
bucket = "foo-versioning-test1"
versioning = null
} However, I think it doesn't make sense setting |
The provider should make a call of GetBucketVersioning if the config has |
FYI: I found this issue had been already fixed in #22221 in v3.70.0 |
Closing this as suggested the fix is available in provider versions as early as |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
This issue was originally opened by @henrikb123 as hashicorp/terraform#24350. It was migrated here as a result of the provider split. The original body of the issue is below.
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
When use_versioning is set to false I expect the bucket to be created without versioning and with versioning never being enabled on the bucket.
Actual Behavior
From observation it seems like Terraform is first creating the bucket with versioning enabled, then afterwards disabling versioning. This leads to a different behavior compared to expected: all deleted objects are not fully deleted but leave behind 'delete markers', making it hard to e.g. programatically delete empty the bucket (e.g. only bucket owner can remove delete markers).
Steps to Reproduce
terraform init
terraform apply
aws s3 cp foo.txt s3://bucket_name/foo.txt
aws s3 rm s3://bucket_name/foo.txt
terraform destroy
Step 5 will fail complaining of bucket not being empty.
Additional Context
References
The text was updated successfully, but these errors were encountered: