Skip to main content
The terraform-aws-s3-bucket module repository includes a set of fully-working example configurations. Each example can be deployed as-is or used as a starting point for your own configuration.

Complete

A comprehensive example with most supported features enabled — versioning, encryption, lifecycle rules, CORS, website hosting, logging, and more.

Cross-Region Replication

Demonstrates setting up Cross-Region Replication (CRR) between two S3 buckets in different AWS regions, including the required IAM role.

S3 Notifications

Configures S3 event notifications to Lambda functions, SQS queues, and SNS topics using the notification submodule.

S3 Object

Demonstrates managing S3 bucket objects (files) using the object submodule, including content uploads, metadata, and encryption.

S3 Analytics

Shows how to configure S3 Analytics to analyze storage access patterns and identify data that should be transitioned to a different storage class.

S3 Inventory

Configures S3 Inventory to generate regular reports of objects in your bucket, including metadata and encryption status.

Account-Level Public Access Block

Demonstrates managing S3 account-level Public Access Block settings using the account-public-access submodule.

S3 Directory Bucket

Creates an S3 Directory Bucket — a high-performance bucket type optimized for latency-sensitive use cases in a single Availability Zone.

S3 Table Bucket

Creates an S3 Table Bucket for storing Apache Iceberg tables, with encryption, maintenance configuration, and table creation.

Running an Example

To run any of the examples locally:
# Clone the repository
git clone https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git
cd terraform-aws-s3-bucket/examples/complete

# Initialize and apply
terraform init
terraform plan
terraform apply
Each example directory contains its own main.tf, variables.tf, and outputs.tf. Review the README.md within each example directory for specific instructions and prerequisites.

Quick Start Snippets

Private bucket with versioning

module "s3_bucket" {
  source = "terraform-aws-modules/s3-bucket/aws"

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

  control_object_ownership = true
  object_ownership         = "ObjectWriter"

  versioning = {
    enabled = true
  }
}

Bucket for ELB access logs

module "s3_bucket_for_logs" {
  source = "terraform-aws-modules/s3-bucket/aws"

  bucket = "my-s3-bucket-for-logs"
  acl    = "log-delivery-write"

  force_destroy = true

  control_object_ownership = true
  object_ownership         = "ObjectWriter"

  attach_elb_log_delivery_policy = true
}

Bucket for WAF logs

module "s3_bucket_for_waf_logs" {
  source = "terraform-aws-modules/s3-bucket/aws"

  bucket = "my-s3-bucket-for-waf-logs"

  force_destroy = true

  control_object_ownership = true
  object_ownership         = "ObjectWriter"

  attach_waf_log_delivery_policy = true
}

Build docs developers (and LLMs) love