← Back to docsRecipe
Recipe: S3 lifecycle policy writer
Automatically transition objects between storage classes and expire stale data using Meridian-managed lifecycle rules. Define rules once, apply across buckets.
Prerequisites
- Meridian agent v2.4+ installed on the target account
- Write access to the S3 buckets you want to govern
- IAM role with
s3:PutBucketLifecycleConfiguration
Step 1 — Define the rule set
Create a JSON policy file. Meridian supports prefix filters, tag-based targeting, and abort-incomplete-multipart-upload cleanup.
{
"Rules": [
{
"Id": "transition-to-ia",
"Prefix": "logs/",
"Status": "Enabled",
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" }
]
},
{
"Id": "expire-old-backups",
"Prefix": "backups/",
"Status": "Enabled",
"Expiration": { "Days": 90 }
}
]
}Step 2 — Apply with Meridian
Use the CLI to push the policy. Meridian validates the JSON schema before sending it to the S3 API.
meridian s3 lifecycle apply \ --bucket my-company-logs \ --policy-file lifecycle.json \ --region us-east-1
Step 3 — Verify
Confirm the policy is active. Meridian surfaces drift detection if someone mutates the rule outside the approved workflow.
meridian s3 lifecycle status --bucket my-company-logs