S3 Lifecycle to Glacier
π¦ Overviewβ
This Terraform module applies an Amazon S3 lifecycle policy that automatically transitions objects to the GLACIER storage class after a specified number of days.
Itβs ideal for archiving infrequently accessed data, reducing long-term storage costs, and meeting compliance needs for cold data retention.
β Key Featuresβ
- Transitions S3 objects to
GLACIERafter a configurable number of days - Supports optional prefix filtering to target specific object sets
- Reduces storage costs in large-scale environments
- Built for long-term data compliance and archival automation
πΌ Use Casesβ
- Regulatory data retention with low access frequency
- Archival of logs, exports, and backups
- Storage cost reduction in S3-heavy workloads
- Cold storage lifecycle enforcement in production or backup buckets
π₯ Input Variablesβ
| Name | Type | Description |
|---|---|---|
| region | string | AWS region where the S3 bucket is located |
| bucket_name | string | Name of the existing S3 bucket to apply the lifecycle policy |
| transition_days | number | Number of days after which to move objects to GLACIER |
| filter_prefix | string | (Optional) Prefix to filter target objects (e.g., "logs/") |
| environment | string | Tag to specify the deployment environment (e.g., dev, staging, prod) |
π€ Outputsβ
| Name | Description |
|---|---|
| bucket_name | The name of the S3 bucket receiving the rule |
| rule_id | The identifier of the applied lifecycle rule |
π Deployment Readinessβ
- β Compatible with Terraform 1.0+
- β Tested with AWS provider 5.x
- π§ͺ Requires an existing S3 bucket and IAM permissions for lifecycle policy management
π οΈ Example Usageβ
module "s3_lifecycle_to_glacier" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//storage/s3-lifecycle-to-glacier?ref=v1.0.0"
region = "us-east-1"
bucket_name = "archiphire-data-store"
transition_days = 30
filter_prefix = ""
environment = "prod"
}
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 remove only the lifecycle configuration. The S3 bucket and its contents will remain unless deleted separately.
π‘οΈ Notesβ
This is a Level 1 module designed for targeted cold-storage automation. For full lifecycle and archival strategies, consider pairing with:
s3-lifecycle-expire s3-lifecycle-intelligent-tiering glacier-vault (for non-S3 object archival)
π 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.