AWS lifecycle rule permanently delete noncurrent versions of objects not working

0

I have versioning enabled in my bucket. Rule Json configuration is attached

1- I created one test bucket and uploaded 2 images. Then, I manually converted my images to Standard-IA, so now the standard versions of those images are there.

2- I created a lifecycle rule to permanently delete noncurrent versions with 1 day on this setting: "Days after objects become noncurrent".

Now, almost 2 days have passed, but my noncurrent (standard) images are still in the bucket.

This is my configuration

{ "Rules": [ { "ID": "Delete Standard noncurrent version", "Filter": {}, "Status": "Enabled", "NoncurrentVersionExpiration": { "NoncurrentDays": 1 } } ] }

Life cycle creation and modification time

June 13, 2024, 04:22:13 (UTC+05:00) => June 12 11:22:13 (UTC)

June 13, 2024, 05:29:54 (UTC+05:00) => June 12 12:29:54 (UTC)

This is the images code

{
    "Versions": [
        {
            "ETag": "\"5f3ac6647fa7685f7c392dde0a8d6467\"",
            "Size": 4070,
            "StorageClass": "STANDARD_IA",
            "Key": "38292/1718231083_666a202b8c45e.jpeg",
            "VersionId": ".ESO54M9LW0wBjMf91Or6fWEICflccXF",
            "IsLatest": true,
            "LastModified": "2024-06-12T22:25:18+00:00",
            "Owner": {
                "DisplayName": "hidden",
                "ID": "6d793b79e5e1fff5177dd4354ebac0be08e867bfe506bb260fd376c171d2afed"
            }
        },
        {
            "ETag": "\"5f3ac6647fa7685f7c392dde0a8d6467\"",
            "Size": 4070,
            "StorageClass": "STANDARD",
            "Key": "38292/1718231083_666a202b8c45e.jpeg",
            "VersionId": "vp0BMmf3m5XZkx4kys3QrC6r66GWTy2b",
            "IsLatest": false,
            "LastModified": "2024-06-12T22:24:46+00:00",
            "Owner": {
                "DisplayName": "hidden",
                "ID": "6d793b79e5e1fff5177dd4354ebac0be08e867bfe506bb260fd376c171d2afed"
            }
        }
		]

Please guide me if I'm doing anything wrong.

asked 10 months ago564 views
2 Answers
2

Your configuration looks correct to me. The rules for applying lifecycle rules are explained in detail on this page in S3's documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#intro-lifecycle-rules-number-of-days

The first object in the Standard storage class became a non-current version on 2024-06-12T22:25:18+00:00 when it was superseded by the new object with the same key and in the Standard-IA class. The lifecycle rule would calculate the time for permanent deletion by first adding 24 hours to the time the object became non-current, which would be 2024-06-13T22:25:18+00:00, and rounding the result up to the next day at midnight UTC. That would make 2024-06-14T00:00:00+00:00 the time for the previous version to be deleted permanently.

That time has already passed, so the previous object version should be deleted by now, but as I pointed out earlier, it's not an instantaneous operation but may take a variable time to execute. For billing purposes, the object should be considered as deleted at 2024-06-14T00:00:00+00:00, however.

I suggest you wait until tomorrow evening to check that the previous object version has disappeared. Your configuration and test scenario appear quite correct.

EXPERT
answered 10 months ago
profile picture
EXPERT
reviewed 10 months ago
profile picture
EXPERT
reviewed 10 months ago
  • okay I will wait for tomorrow and then update here.

    One more thing. If I want to transition new objects to convert into standard IA after 30 days. I can adjust Permanent delete and transition in one rule or better to create two rules.

    Thank you so much for again looking at this

  • Professionally, my strong preference would be to configure previous version deletion and transitioning for cost efficiency in separate rules. Technically, they'll work the same either way, but separating them and naming them clearly makes it more intuitive for humans to understand what the rules are set to do at a glance, it allows disabling rules temporarily without having to modify the rule structure and to remember to revert the changes later, and if you want to apply different filters to the two actions, the rules will have to be separated.

  • Hey Leo. Just to update you that one noncurrent object successfully deleted. Thank you so much for your time and I also accepted the answer.

  • Leo just last thing please. Can I see the lifecycle report? e.g: today lifecycle deleted 1000 objects?

  • If you had S3 server access logging enabled for your bucket (https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html), the individual object actions performed by lifecycle rules were logged there. If not, you can get a numeric overview from CloudWatch metrics, updated once per day, but individual object-level details aren't logged if logging isn't enabled for the bucket.

2

Your lifecycle rule looks correct. The rule executes once per day, starting at midnight UTC, and it can take a variable amount of time after starting to complete. The 1 day after expiration rule means literally 24 hours after the exact timestamp when the objects expired, so if you deleted or overwrote them at 14:00 UTC, for example, they would only be 10 hours old at midnight UTC the following day. They would only meet the deletion condition one day later at midnight UTC.

If you're sure the objects in the Standard class are non-current versions (meaning you only see them in the console when you switch the "Show versions" option on), I suggest you wait one more day and check around 18:00 UTC to see if the previous versions are gone. The deletion process isn't instantaneous, so they won't be gone at 0:01 UTC yet.

EXPERT
answered 10 months ago
profile picture
EXPERT
reviewed 10 months ago
profile picture
EXPERT
reviewed 10 months ago
  • Hey Leo I updated my question with additional details of images and creation, modification time of lifecycle rule. I wish to delete standard images automatically. as I've manually converted Standard images to Standard-IA Thank you for your time.

  • Hey Leo. Just to update you that one noncurrent object successfully deleted. Thank you so much for your time and I also accepted the answer.

  • It's good to hear that your setup is working and what's even better, that your configuration was quite correct all along.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions