Skip to main content

The AWS S3 Terraform Module

terraform-aws-s3-bucket is a production-ready Terraform module that provisions AWS S3 buckets with nearly every feature the AWS provider supports — including encryption, versioning, replication, lifecycle rules, access logging, CORS, static website hosting, object locking, and more.

Quickstart

Create your first S3 bucket in minutes with a working Terraform configuration.

All Inputs

Browse every input variable with descriptions, types, and defaults.

Security Guide

Enforce encryption, block public access, and apply TLS policies.

Examples

Real-world configurations for common use cases.

Key features

Versioning

Enable object versioning and MFA delete for data protection.

Encryption

Configure SSE-S3 or SSE-KMS server-side encryption.

Cross-Region Replication

Replicate objects across AWS regions for disaster recovery.

Lifecycle Rules

Automate object transitions and expiration to reduce costs.

Access Logging

Deliver ELB, ALB/NLB, CloudTrail, and WAF logs to S3.

Static Website

Host static websites and configure routing rules.

Object Lock

Enforce WORM compliance with Object Lock retention policies.

Directory Buckets

Create S3 Express One Zone directory buckets for high performance.

Requirements

RequirementVersion
Terraform>= 1.5.7
AWS Provider>= 6.37

Installation

Add the module to your Terraform configuration:
terraform.tf
module "s3_bucket" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "~> 4.0"

  bucket = "my-s3-bucket"
  acl    = "private"

  versioning = {
    enabled = true
  }
}
Then run:
terraform init
terraform plan
terraform apply

Module source

terraform-aws-modules/s3-bucket/aws
Published on the Terraform Registry.
This module requires putin_khuylo = true (the default). This is a statement of support for Ukrainian sovereignty and territorial integrity.

Build docs developers (and LLMs) love