Mudasar Yasin
Mudasar Yasin

Reputation: 639

Lifecycle policy on S3 not working

I have simply enabled a file cycle policy on a bucket in Amazon S3. This is the configuration:

root@iserver:~# aws s3api get-bucket-lifecycle-configuration --bucket ee-shares --profile s3toglacier
{
"Rules": [
{
"Status": "Enabled",
"Prefix": "",
"Transitions": [
{
"Days": 180,
"StorageClass": "GLACIER"
}
],
"ID": "test"
}
]
}

But I cannot see data on Glacier and objects older then 180 days do not show "Initial Restore" option in S3.

Upvotes: 10

Views: 12063

Answers (2)

Mahesh Chahar
Mahesh Chahar

Reputation: 1

You can temporarily add expiry (for e.g expire current versions of objects) of objects in the same lifecycle rule and set days after object creation to a large number (for e.g 2147483647). This will allow you to test if your lifecycle policy is attached to your objects or not.

export BUCKET_NAME=YOUR_BUCKET_NAME
export KEY_NAME=KEY_NAME

aws s3 api head-object --bucket $BUCKET_NAME --key KEY_NAME

Output:
{
    "AcceptRanges": "bytes",
    "Expiration": "expiry-date=\"Fri, 30 Sep 2022 00:00:00 GMT\", rule-id=\"transistion-glacier-expire\"",
    "LastModified": "2022-07-01T08:53:49+00:00",
    "ContentLength": 13932,
    "ETag": "\"90ef2da5ad155a608342f88b51f36111\"",
    "ContentType": "text/html",
    "Metadata": {}
}

Now we can see Expiration header and it will provide details of lifecycle rule associated with it.

Note: Remember to remove above test expiry rule from your lifecycle policy after testing your changes.

Upvotes: 0

John Rotenstein
John Rotenstein

Reputation: 269430

Amazon S3 lifecycle policies do not execute immediately. Allow up to 24 hours for them to archive content.

Once archived, the objects will still appear in Amazon S3, but their storage class will be set to Glacier.

Upvotes: 19

Related Questions