Bird
Raised Fist0
GCPcloud~20 mins

Lifecycle management rules in GCP - 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
🎖️
Lifecycle Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Understanding GCS Lifecycle Rule Effect

You have a Google Cloud Storage bucket with this lifecycle rule:

{"rule": [{"action": {"type": "Delete"}, "condition": {"age": 30}}]}

What happens to objects in this bucket?

AObjects older than 30 days are automatically deleted.
BObjects are archived to Nearline storage after 30 days.
CObjects are encrypted after 30 days.
DObjects are made publicly readable after 30 days.
Attempts:
2 left
💡 Hint

Think about what the 'Delete' action means in lifecycle rules.

Configuration
intermediate
2:00remaining
Correct Lifecycle Rule to Archive Objects

Which lifecycle rule configuration archives objects to Coldline storage after 60 days?

A{"rule": [{"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"}, "condition": {"age": 60}}]}
B{"rule": [{"action": {"type": "Delete"}, "condition": {"age": 60}}]}
C{"rule": [{"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 60}}]}
D{"rule": [{"action": {"type": "SetStorageClass", "storageClass": "ARCHIVE"}, "condition": {"age": 30}}]}
Attempts:
2 left
💡 Hint

Look for the action type that changes storage class and the correct target class.

Architecture
advanced
2:30remaining
Designing Lifecycle Rules for Cost Optimization

You want to design lifecycle rules for a bucket storing logs. Logs should be stored in Standard storage for 7 days, then moved to Nearline for 30 days, then to Coldline for 90 days, and finally deleted after 365 days. Which lifecycle rule set achieves this?

A[{"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"}, "condition": {"age": 7}}, {"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 37}}, {"action": {"type": "Delete"}, "condition": {"age": 365}}]
B[{"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"}, "condition": {"age": 7}}, {"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 37}}, {"action": {"type": "Delete"}, "condition": {"age": 90}}]
C[{"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"}, "condition": {"age": 7}}, {"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 97}}, {"action": {"type": "Delete"}, "condition": {"age": 365}}]
D]}}563 :"ega"{ :"noitidnoc" ,}"eteleD" :"epyt"{ :"noitca"{ ,}}73 :"ega"{ :"noitidnoc" ,}"ENILDLOC" :"ssalCegarots" ,"ssalCegarotSteS" :"epyt"{ :"noitca"{ ,}}7 :"ega"{ :"noitidnoc" ,}"ENILRAEN" :"ssalCegarots" ,"ssalCegarotSteS" :"epyt"{ :"noitca"{[
Attempts:
2 left
💡 Hint

Calculate cumulative days for each storage class transition.

security
advanced
2:00remaining
Lifecycle Rule Impact on Object Versioning

A bucket has object versioning enabled. It has this lifecycle rule:

{"rule": [{"action": {"type": "Delete"}, "condition": {"isLive": false, "age": 30}}]}

What happens to noncurrent object versions?

AAll object versions are deleted after 30 days.
BNo versions are deleted because versioning is enabled.
COnly live versions older than 30 days are deleted.
DNoncurrent versions older than 30 days are deleted automatically.
Attempts:
2 left
💡 Hint

Check the condition 'isLive': false and what it means.

Best Practice
expert
3:00remaining
Choosing Lifecycle Rules for Compliance and Cost

Your company must retain data for 7 years for compliance. Data should be stored cost-effectively after 1 year. Which lifecycle rule strategy meets compliance and cost goals?

ASet lifecycle rule to delete objects after 1 year and transition to Coldline storage after 7 years.
BSet lifecycle rule to delete objects after 7 years and transition to Coldline storage after 1 year.
CSet lifecycle rule to delete objects after 7 years and transition to Nearline storage after 7 years.
DSet lifecycle rule to delete objects after 7 years and transition to Archive storage after 1 year.
Attempts:
2 left
💡 Hint

Think about when to move data to cheaper storage and when to delete it.

Practice

(1/5)
1. What is the main purpose of lifecycle management rules in Google Cloud Storage?
easy
A. To encrypt files before uploading
B. To manually upload files to the cloud storage
C. To create backups of files every hour
D. To automatically delete or move files based on conditions like age or storage class

Solution

  1. Step 1: Understand lifecycle rules function

    Lifecycle rules automate file management by applying actions like deletion or moving files based on set conditions.
  2. Step 2: Compare options with lifecycle purpose

    Only To automatically delete or move files based on conditions like age or storage class describes automatic file management based on age or storage class, which matches lifecycle rules.
  3. Final Answer:

    To automatically delete or move files based on conditions like age or storage class -> Option D
  4. Quick Check:

    Lifecycle rules automate file management = A [OK]
Hint: Lifecycle rules automate file cleanup and movement [OK]
Common Mistakes:
  • Confusing lifecycle rules with manual file upload
  • Thinking lifecycle rules create backups
  • Assuming lifecycle rules handle encryption
2. Which of the following is the correct syntax snippet to define a lifecycle rule that deletes objects older than 30 days in a GCP bucket JSON configuration?
easy
A. {"rules": [{"action": {"type": "Delete"}, "condition": {"age": 30}}]}
B. {"rule": [{"action": {"type": "Remove"}, "condition": {"age": 30}}]}
C. {"rule": [{"action": {"type": "Delete"}, "condition": {"age": 30}}]}
D. {"rule": [{"action": {"type": "Delete"}, "condition": {"days": 30}}]}

Solution

  1. Step 1: Identify correct key names in lifecycle JSON

    The lifecycle configuration uses the key "rules" (plural) for the list of rules, not "rule".
  2. Step 2: Check action type and condition keys

    Action type must be "Delete" and condition uses "age" in days. {"rules": [{"action": {"type": "Delete"}, "condition": {"age": 30}}]} correctly uses "rules", "Delete", and "age".
  3. Final Answer:

    {"rules": [{"action": {"type": "Delete"}, "condition": {"age": 30}}]} -> Option A
  4. Quick Check:

    Correct lifecycle JSON uses "rules" and "age" = C [OK]
Hint: Use "rules" key and "age" condition for lifecycle JSON [OK]
Common Mistakes:
  • Using singular "rule" instead of "rules"
  • Using "Remove" instead of "Delete" for action
  • Using "days" instead of "age" in condition
3. Given this lifecycle rule JSON snippet for a GCP bucket:
{"rules": [{"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"}, "condition": {"age": 60}}]}

What happens to objects older than 60 days?
medium
A. They remain in the current storage class
B. They are deleted immediately
C. They are moved to the NEARLINE storage class
D. They are archived to Coldline storage

Solution

  1. Step 1: Understand action type in lifecycle rule

    The action type "SetStorageClass" changes the storage class of objects matching the condition.
  2. Step 2: Analyze condition and effect

    The condition "age": 60 means objects older than 60 days will be moved to the "NEARLINE" storage class.
  3. Final Answer:

    They are moved to the NEARLINE storage class -> Option C
  4. Quick Check:

    SetStorageClass action moves objects = A [OK]
Hint: SetStorageClass moves files; Delete removes them [OK]
Common Mistakes:
  • Confusing SetStorageClass with Delete action
  • Assuming objects are deleted instead of moved
  • Thinking NEARLINE means Coldline storage
4. You wrote this lifecycle rule JSON to delete objects older than 90 days:
{"rule": [{"action": {"type": "Delete"}, "condition": {"age": 90}}]}

Why does this rule not work as expected?
medium
A. The key should be "rules" not "rule"
B. The action type "Delete" is invalid
C. The condition "age" must be a string, not a number
D. The age value must be less than 30

Solution

  1. Step 1: Check lifecycle JSON key names

    The lifecycle configuration requires the key "rules" (plural) for the list of rules, not "rule".
  2. Step 2: Validate action and condition correctness

    "Delete" is a valid action type, and "age" is correctly a number. Age can be any positive number.
  3. Final Answer:

    The key should be "rules" not "rule" -> Option A
  4. Quick Check:

    Correct key is "rules" = B [OK]
Hint: Use "rules" key for lifecycle rules array [OK]
Common Mistakes:
  • Using singular "rule" instead of "rules"
  • Thinking "Delete" is invalid action
  • Believing age must be string or less than 30
5. You want to create a lifecycle rule that moves objects to Coldline storage after 30 days and deletes them after 365 days. Which JSON configuration correctly implements this?
hard
A. {"rules": [{"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 365}}, {"action": {"type": "Delete"}, "condition": {"age": 30}}]}
B. {"rules": [{"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 30}}, {"action": {"type": "Delete"}, "condition": {"age": 365}}]}
C. {"rules": [{"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"}, "condition": {"age": 30}}, {"action": {"type": "Delete"}, "condition": {"age": 365}}]}
D. {"rules": [{"action": {"type": "Delete"}, "condition": {"age": 30}}, {"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 365}}]}

Solution

  1. Step 1: Identify correct order of lifecycle actions

    Objects should first move to Coldline after 30 days, then be deleted after 365 days. The order matters for correct lifecycle behavior.
  2. Step 2: Check storage class and age conditions

    {"rules": [{"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 30}}, {"action": {"type": "Delete"}, "condition": {"age": 365}}]} correctly sets "SetStorageClass" to "COLDLINE" at age 30, then "Delete" at age 365.
  3. Final Answer:

    {"rules": [{"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"}, "condition": {"age": 30}}, {"action": {"type": "Delete"}, "condition": {"age": 365}}]} -> Option B
  4. Quick Check:

    Move to Coldline at 30 days, delete at 365 days = D [OK]
Hint: Order rules: move storage first, then delete later [OK]
Common Mistakes:
  • Reversing delete and move actions order
  • Using wrong storage class name
  • Setting wrong age values for actions