I naively tagged S3 objects with a common key, but arbitrary values (a UUID
per batch), believing it would be "easy enough" to go back and delete every object with the specified tag.
So far, my testing suggests that if I specify a lifecycle rule which filters based on key-only (no value), then it matches only objects which also have the key and no value, rather than matching all objects with that key regardless of value.
I'm currently waiting for midnight UTC just to make sure that the issue isn't between Terraform and Amazon S3. But if there's a known way to specify apply rule to all objects with tag-key K
, that would be super helpful; the documentation I've found to date isn't quite that clear.
Bit of terraform for completeness:
resource "aws_s3_bucket" "my_s3_bucket" {
...
lifecycle_rule {
id = "Tagged current version expiration"
prefix = "my_prefix/"
tags = {
recyclable = ""
}
enabled = var.tagged_current_version_expiration_enabled
noncurrent_version_expiration {
days = var.tagged_noncurrent_version_expiration_days
}
expiration {
days = var.tagged_current_version_expiration_days
}
}
...
}