- Create a file called
lifecycle.json
and append the below into it :
{
"Rules": [
{
"ID": "Delete files older than 60 days",
"Prefix": "",
"Status": "Enabled",
"Expiration":
{
"Days": 60
}
}
]
}
- Run the below command to set the policy on the existing bucket :
aws s3api put-bucket-lifecycle-configuration --bucket <bucket-name> --lifecycle-configuration file://lifecycle.json