Bird
Raised Fist0
AWScloud~20 mins

S3 lifecycle rules in AWS - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
S3 Lifecycle Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What happens when an S3 lifecycle rule transitions objects to Glacier after 30 days?

You have an S3 bucket with a lifecycle rule that moves objects to Glacier storage class after 30 days. What is the expected behavior for objects older than 30 days?

AObjects older than 30 days are immediately deleted from S3 and only stored in Glacier.
BObjects older than 30 days are transitioned to Glacier storage class but remain accessible with a retrieval delay.
CObjects older than 30 days remain in S3 Standard storage and are not moved.
DObjects older than 30 days are copied to Glacier but also remain in S3 Standard storage.
Attempts:
2 left
💡 Hint

Think about how S3 lifecycle transitions work with Glacier storage class.

Configuration
intermediate
2:00remaining
Which lifecycle rule configuration deletes objects after 365 days?

Choose the correct JSON snippet for an S3 lifecycle rule that deletes objects 365 days after creation.

A{ "Rules": [{ "ID": "DeleteAfter365", "Status": "Enabled", "Expiration": { "Days": 365 } }] }
B{ "Rules": [{ "ID": "DeleteAfter365", "Status": "Enabled", "Transition": { "Days": 365, "StorageClass": "GLACIER" } }] }
C{ "Rules": [{ "ID": "DeleteAfter365", "Status": "Enabled", "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 365 } }] }
D{ "Rules": [{ "ID": "DeleteAfter365", "Status": "Enabled", "Expiration": { "Date": "365" } }] }
Attempts:
2 left
💡 Hint

Expiration rules use the 'Days' field to specify deletion timing.

security
advanced
2:00remaining
What is the security risk of enabling lifecycle rules that permanently delete objects without versioning?

You enable lifecycle rules that permanently delete objects after 30 days on a bucket without versioning. What is the main security risk?

ALifecycle rules automatically encrypt deleted objects, preventing data leaks.
BObjects can be recovered after deletion using versioning snapshots.
CObjects are archived to Glacier before deletion, so no data is lost.
DDeleted objects cannot be recovered, risking accidental data loss.
Attempts:
2 left
💡 Hint

Consider what happens when versioning is not enabled and objects are deleted.

Architecture
advanced
2:00remaining
How to design lifecycle rules for cost optimization with frequent access and archival?

You have a bucket with objects accessed frequently for 60 days, then rarely accessed for 180 days, then archived. Which lifecycle rule sequence optimizes cost?

ATransition to GLACIER after 60 days, then to STANDARD_IA after 180 days, then delete after 365 days.
BDelete after 60 days, transition to GLACIER after 180 days, then to STANDARD_IA after 365 days.
CTransition to STANDARD_IA after 60 days, then to GLACIER after 180 days, then delete after 365 days.
DKeep all objects in STANDARD storage for 365 days, then delete.
Attempts:
2 left
💡 Hint

Think about storage classes for frequent and infrequent access and cost savings.

Best Practice
expert
2:00remaining
What is the best practice to prevent accidental deletion with lifecycle rules on a versioned bucket?

You have enabled versioning on an S3 bucket and lifecycle rules that delete objects after 30 days. What is the best practice to avoid accidental permanent deletion?

AConfigure lifecycle rules to delete only non-current versions after 30 days and keep current versions.
BDisable versioning to simplify lifecycle rule management.
CSet lifecycle rules to delete all versions immediately after 30 days.
DUse lifecycle rules to transition all versions to GLACIER instead of deleting.
Attempts:
2 left
💡 Hint

Consider how versioning interacts with lifecycle expiration of current and non-current versions.

Practice

(1/5)
1. What is the main purpose of an S3 lifecycle rule?
easy
A. To automatically move or delete files based on time to save costs
B. To manually upload files to S3 buckets
C. To create backups of files in S3
D. To encrypt files stored in S3

Solution

  1. Step 1: Understand lifecycle rule purpose

    S3 lifecycle rules automate management of files by moving or deleting them after a set time.
  2. Step 2: Compare options with lifecycle rule function

    Only To automatically move or delete files based on time to save costs describes automatic moving or deleting files to save costs, which matches lifecycle rules.
  3. Final Answer:

    To automatically move or delete files based on time to save costs -> Option A
  4. Quick Check:

    Lifecycle rules automate file management = C [OK]
Hint: Lifecycle rules automate file moves or deletes by time [OK]
Common Mistakes:
  • Confusing lifecycle rules with manual upload
  • Thinking lifecycle rules create backups
  • Assuming lifecycle rules encrypt files
2. Which of the following is the correct JSON snippet to define a lifecycle rule that deletes objects after 30 days?
easy
A. {"Rules": [{"Status": "Disabled", "Expiration": {"Days": 30}}]}
B. {"Rules": [{"Status": "Enabled", "Transition": {"Days": 30}}]}
C. {"Rules": [{"Status": "Enabled", "Expiration": {"Days": 30}}]}
D. {"Rules": [{"Status": "Enabled", "Expiration": {"Date": 30}}]}

Solution

  1. Step 1: Identify correct lifecycle rule syntax for expiration

    The expiration action uses "Expiration" with "Days" key and rule must be "Enabled".
  2. Step 2: Check each option for correct keys and values

    {"Rules": [{"Status": "Enabled", "Expiration": {"Days": 30}}]} uses "Expiration" with "Days":30 and "Status":"Enabled" which is correct. {"Rules": [{"Status": "Enabled", "Transition": {"Days": 30}}]} uses "Transition" which is for storage class change, not deletion. {"Rules": [{"Status": "Disabled", "Expiration": {"Days": 30}}]} disables the rule. {"Rules": [{"Status": "Enabled", "Expiration": {"Date": 30}}]} uses "Date" instead of "Days" which is invalid.
  3. Final Answer:

    {"Rules": [{"Status": "Enabled", "Expiration": {"Days": 30}}]} -> Option C
  4. Quick Check:

    Expiration with Days and Enabled status = A [OK]
Hint: Expiration uses "Days" and rule must be enabled [OK]
Common Mistakes:
  • Using Transition instead of Expiration for deletion
  • Setting rule status to Disabled
  • Using Date instead of Days for expiration
3. Given this lifecycle rule snippet, what happens to objects after 60 days?
{
  "Rules": [{
    "Status": "Enabled",
    "Prefix": "logs/",
    "Transition": {"Days": 60, "StorageClass": "GLACIER"}
  }]
}
medium
A. Objects in the 'logs/' folder are moved to Glacier storage after 60 days
B. Objects in the 'logs/' folder are deleted after 60 days
C. All objects in the bucket are moved to Glacier after 60 days
D. Objects in the 'logs/' folder are archived immediately

Solution

  1. Step 1: Understand the Transition action with Prefix

    The rule targets objects with prefix "logs/" and transitions them to Glacier after 60 days.
  2. Step 2: Analyze options against rule behavior

    Objects in the 'logs/' folder are moved to Glacier storage after 60 days correctly states objects in 'logs/' move to Glacier after 60 days. Objects in the 'logs/' folder are deleted after 60 days incorrectly says deletion. All objects in the bucket are moved to Glacier after 60 days incorrectly applies to all objects, not just prefix. Objects in the 'logs/' folder are archived immediately says immediate archive which is wrong.
  3. Final Answer:

    Objects in the 'logs/' folder are moved to Glacier storage after 60 days -> Option A
  4. Quick Check:

    Transition with prefix moves files after days = A [OK]
Hint: Transition moves files after days, prefix limits target [OK]
Common Mistakes:
  • Confusing Transition with Expiration (deletion)
  • Ignoring the prefix filter
  • Assuming all bucket objects are affected
4. You wrote this lifecycle rule but it does not delete files after 90 days:
{
  "Rules": [{
    "Status": "Enabled",
    "Expiration": {"Days": 90}
  }]
}
What is the likely problem?
medium
A. Missing a required rule ID
B. Status should be set to Disabled to activate
C. Expiration action cannot be used without Transition
D. Rule is missing a filter or prefix to target objects

Solution

  1. Step 1: Recall S3 lifecycle rule required fields

    Every lifecycle rule requires a unique "ID" field only if using AWS CLI or SDKs; however, in JSON configuration for S3 console, "ID" is optional. Filter or prefix is required to target objects; otherwise, the rule applies to all objects.
  2. Step 2: Analyze given rule

    The rule lacks a filter or prefix, so it applies to all objects. If files are not deleting, likely the rule is not targeting the intended objects. Missing "ID" is not always mandatory (A wrong). Status "Enabled" is correct (B wrong). Expiration works standalone (C wrong). Filter or prefix is needed to target specific objects (D correct).
  3. Final Answer:

    Rule is missing a filter or prefix to target objects -> Option D
  4. Quick Check:

    Missing filter or prefix means rule may not target intended objects = D [OK]
Hint: Filter or prefix is needed to target objects for deletion [OK]
Common Mistakes:
  • Believing filter or prefix is optional (A)
  • Thinking Expiration requires Transition (C)
  • Status should be Disabled to activate (B)
5. You want to save costs by moving files older than 30 days to STANDARD_IA storage and delete files older than 365 days, but only for files in the archive/ folder. Which lifecycle rule setup achieves this?
hard
A. { "Rules": [{ "Status": "Enabled", "Prefix": "archive/", "Transition": {"Days": 365, "StorageClass": "STANDARD_IA"}, "Expiration": {"Days": 30} }] }
B. { "Rules": [{ "Status": "Enabled", "Filter": {"Prefix": "archive/"}, "Transitions": [{"Days": 30, "StorageClass": "STANDARD_IA"}], "Expiration": {"Days": 365} }] }
C. { "Rules": [{ "Status": "Enabled", "Filter": {"Prefix": "archive/"}, "Transition": {"Days": 365, "StorageClass": "STANDARD_IA"}, "Expiration": {"Days": 30} }] }
D. { "Rules": [{ "Status": "Enabled", "Filter": {"Prefix": "archive/"}, "Transitions": [{"Days": 365, "StorageClass": "STANDARD_IA"}], "Expiration": {"Days": 30} }] }

Solution

  1. Step 1: Identify correct keys for multiple transitions and expiration

    Multiple transitions require "Transitions" array. Expiration is separate. Filter with Prefix targets 'archive/'.
  2. Step 2: Check each option for correct days and storage class order

    { "Rules": [{ "Status": "Enabled", "Prefix": "archive/", "Transition": {"Days": 365, "StorageClass": "STANDARD_IA"}, "Expiration": {"Days": 30} }] } reverses days and expiration. { "Rules": [{ "Status": "Enabled", "Filter": {"Prefix": "archive/"}, "Transitions": [{"Days": 30, "StorageClass": "STANDARD_IA"}], "Expiration": {"Days": 365} }] } correctly uses "Transitions" array with 30 days to STANDARD_IA and expiration at 365 days, with filter prefix. { "Rules": [{ "Status": "Enabled", "Filter": {"Prefix": "archive/"}, "Transition": {"Days": 365, "StorageClass": "STANDARD_IA"}, "Expiration": {"Days": 30} }] } uses singular "Transition" but reverses days (365 to IA, expire 30). { "Rules": [{ "Status": "Enabled", "Filter": {"Prefix": "archive/"}, "Transitions": [{"Days": 365, "StorageClass": "STANDARD_IA"}], "Expiration": {"Days": 30} }] } reverses days and expiration.
  3. Step 3: Choose best practice with multiple transitions

    { "Rules": [{ "Status": "Enabled", "Filter": {"Prefix": "archive/"}, "Transitions": [{"Days": 30, "StorageClass": "STANDARD_IA"}], "Expiration": {"Days": 365} }] } uses "Transitions" array which is best practice for multiple transitions, even if only one here, and matches requirements.
  4. Final Answer:

    Rule with Filter prefix 'archive/', Transitions at 30 days to STANDARD_IA, Expiration at 365 days -> Option B
  5. Quick Check:

    Multiple transitions use "Transitions" array, filter prefix set = B [OK]
Hint: Use "Transitions" array for multiple moves, filter prefix to target folder [OK]
Common Mistakes:
  • Confusing Transition singular vs Transitions array
  • Mixing up days for transition and expiration
  • Not using filter or prefix to limit scope