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โ
| Name | Type | Description |
|---|---|---|
| region | string | AWS region where the S3 bucket will be created |
| bucket_base_name | string | Base name for the bucket (random suffix will be appended) |
| environment | string | Tag to specify the deployment environment (e.g., dev, staging, prod) |
๐ค Outputsโ
| Name | Description |
|---|---|
| bucket_name | The full name of the created S3 bucket |
| bucket_arn | The 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.