Skip to main content

S3 Bucket

๐Ÿ“ฆ Overviewโ€‹

This Terraform module provisions a basic AWS S3 bucket with tagging support and a randomly generated suffix to ensure global uniqueness.
It is intended for general-purpose storage in development, testing, or staging environments.


โœ… Key Featuresโ€‹

  • Generates a globally unique S3 bucket name with random suffix
  • Adds tagging support for environment and name tracking
  • Optional auto-destruction of the bucket when using terraform destroy
  • Lightweight and composable for use in larger infrastructures

๐Ÿ’ผ Use Casesโ€‹

  • General-purpose object storage
  • Temporary buckets for development or CI/CD pipelines
  • Base storage to be extended with lifecycle or logging modules
  • Experimentation and learning environments

๐Ÿ“ฅ Input Variablesโ€‹

NameTypeDescription
regionstringAWS region where the S3 bucket will be created
bucket_base_namestringBase name for the bucket (random suffix will be appended)
environmentstringTag to specify the deployment environment (e.g., dev, staging, prod)

๐Ÿ“ค Outputsโ€‹

NameDescription
bucket_nameThe full name of the created S3 bucket
bucket_arnThe ARN of the created S3 bucket

๐Ÿš€ Deployment Readinessโ€‹

  • โœ… Compatible with Terraform 1.0+
  • โœ… Tested with AWS provider 5.x
  • ๐Ÿงช Requires IAM permissions for S3 and tagging

๐Ÿ› ๏ธ Example Usageโ€‹

module "s3_bucket" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//storage/s3-bucket?ref=v1.0.0"

region = "us-east-1"
bucket_base_name = "archiphire-logs"
environment = "dev"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

๐Ÿงน Cleanup Optionsโ€‹

Terraform Destroy (for test environments):

terraform destroy

or

tofu destroy

โš ๏ธ This will delete the bucket and all objects within. For production environments, use manual deletion to avoid unintentional data loss:

aws s3 rb s3://"bucket_name" --force

๐Ÿ›ก๏ธ Notesโ€‹

This is a Level 1 baseline module. For hardened or policy-restricted buckets, use s3-secure-bucket instead.

๐Ÿ”’ Deployment Package Noticeโ€‹

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.