I'm creating an AWS S3 bucket on which many files will be uploaded.
Since I don't want those file to stay forever, I would like to empty the bucket every month.
I'm using Terraform to do this.
I have the following documentation https://www.terraform.io/docs/providers/aws/r/s3_bucket.html
And the following Terraform configuration:
resource "aws_s3_bucket" "garbage" {
bucket = "garbage-${terraform.workspace}"
acl = "private"
lifecycle {
prevent_destroy = false
}
lifecycle {
prevent_destroy = false
}
lifecycle_rule {
id = tmp
prefix= "tmp/"
enabled = true
expiration {
days = 1
}
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
Even with the documentation, I struggle to find how I could indicate that I want the file to be deleted every month in this bucket.
expiration
policy. Also, I'm not aware that you can empty the bucket using lifecycle policies. You would typically configure objects to expire 30 days after they were created. You could potentially set a date e.g. 2019-12-31 but you would then have to update that policy at the start of each new month. – jarmodlifecycle_rule
parameters? What errors did you get if you did? If you didn't get an error what behaviour did you see vs what you expected? – ydaetskcoR