S3 buckets can be in three states related to versioning:
When the S3 bucket is unversioned or has versioning suspended it means that a new version of an object overwrites an existing one in the S3 bucket.
It can lead to unintentional or intentional information loss.
There is a risk if you answered yes to any of those questions.
It’s recommended to enable S3 versioning and thus to have the possibility to retrieve and restore different versions of an object.
Versioning is disabled by default:
resource "aws_s3_bucket" "example" { # Sensitive
bucket = "example"
}
Versioning is enabled for AWS provider version 4 or above:
resource "aws_s3_bucket" "example" {
bucket = "example"
}
resource "aws_s3_bucket_versioning" "example-versioning" {
bucket = aws_s3_bucket.example.id
versioning_configuration {
status = "Enabled"
}
}
Versioning is enabled for AWS provider version 3 or below:
resource "aws_s3_bucket" "example" {
bucket = "example"
versioning {
enabled = true
}
}