Review S3 bucket MFA Delete use

Consider whether permanent deletion of important object versions needs additional authentication.

Description

On a versioned bucket, MFA Delete requires MFA to permanently delete a specific object version or change versioning state. Ordinary deletes without a version ID do not require this check.

Potential impact

Versioning alone leaves recovery versions at risk if an authorized caller deletes them by mistake or their credentials are compromised.

Remediation

Check retention needs and existing S3 Lifecycle configurations. MFA Delete cannot be combined with Lifecycle configurations. To enable it, the bucket owner’s root user must use an MFA device with the AWS CLI or API. Restrict root access and verify the effective state.

Examples

The excerpts use AWS provider 3.75.2’s inline versioning syntax. In that version, mfa_delete reflects the setting already applied in AWS.

Before

hcl
resource "aws_s3_bucket" "example" {
  bucket = "my-tf-test-bucket"
  acl    = "private"

  versioning {
    enabled = true
  }
}

After

hcl
resource "aws_s3_bucket" "example" {
  bucket = "my-tf-test-bucket"
  acl    = "private"

  versioning {
    enabled    = true
    mfa_delete = true
  }
}

Both examples enable versioning. Before applying the second declaration, verify in AWS that versioning and MFA Delete are both enabled.

References