Skip to main content

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 GLACIER after 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​

NameTypeDescription
regionstringAWS region where the S3 bucket is located
bucket_namestringName of the existing S3 bucket to apply the lifecycle policy
transition_daysnumberNumber of days after which to move objects to GLACIER
filter_prefixstring(Optional) Prefix to filter target objects (e.g., "logs/")
environmentstringTag to specify the deployment environment (e.g., dev, staging, prod)

πŸ“€ Outputs​

NameDescription
bucket_nameThe name of the S3 bucket receiving the rule
rule_idThe 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.