S3 versioning keeps multiple variants of every object in your bucket. EveryDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/terraform-aws-modules/terraform-aws-s3-bucket/llms.txt
Use this file to discover all available pages before exploring further.
PUT, DELETE, and overwrite creates a new version rather than silently replacing the existing one. This makes accidental deletion recoverable and gives you a complete change history at no extra request cost.
Enable versioning
Set theversioning variable with enabled = true:
Status field values
The module accepts thestatus key as an alternative to enabled. Valid string values are:
| Value | Behavior |
|---|---|
"Enabled" | New objects receive a version ID; existing objects get a null version ID. |
"Suspended" | New objects receive a null version ID. Existing versions are preserved. |
true/false) via enabled, or the string directly via status — the module normalises both:
MFA delete
MFA delete requires a second factor for version deletions and for toggling the versioning state. Enable it with themfa_delete key and provide the MFA device serial + current token in mfa:
Object Lock (WORM)
Object Lock prevents objects from being deleted or overwritten for a fixed period or indefinitely. It satisfies Write Once Read Many (WORM) compliance requirements such as SEC 17a-4, CFTC, and FINRA.Object Lock can only be enabled on new buckets. Set
object_lock_enabled = true at bucket creation time.Enable object lock
Configure a default retention rule
Once Object Lock is enabled you can set a default retention rule withobject_lock_configuration:
- COMPLIANCE mode
- GOVERNANCE mode
- Years-based retention
Retention modes compared
| Mode | Who can bypass | Typical use |
|---|---|---|
COMPLIANCE | Nobody | Strict regulatory compliance |
GOVERNANCE | Users with s3:BypassGovernanceRetention | Development and governance workflows |
Versioning output
After applying, retrieve the current versioning state with theaws_s3_bucket_versioning_status output:
"Enabled", "Suspended", or "Disabled".
