Bird
Raised Fist0
AWScloud~20 mins

Time to live (TTL) for expiration in AWS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
TTL Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate
2:00remaining
How does TTL affect item expiration in DynamoDB?

In AWS DynamoDB, when you enable TTL on a table, what happens to items after their TTL timestamp passes?

AItems become inaccessible but remain in the table until manually deleted.
BItems are marked for expiration and typically deleted within 48 hours after the TTL timestamp.
CItems are archived automatically to S3 when TTL expires.
DItems are immediately deleted from the table as soon as the TTL timestamp is reached.
Attempts:
2 left
💡 Hint

Think about how AWS handles background cleanup for expired items.

❓ Configuration
intermediate
2:00remaining
Which DynamoDB attribute type is required for TTL?

When configuring TTL on a DynamoDB table, which attribute type must the TTL attribute have?

ANumber representing Unix epoch time in seconds.
BBoolean indicating if the item should expire.
CBinary data representing a timestamp.
DString representing a date in ISO 8601 format.
Attempts:
2 left
💡 Hint

TTL expects a timestamp in a numeric format.

❓ security
advanced
2:00remaining
What IAM permission is required to enable TTL on a DynamoDB table?

To enable TTL on a DynamoDB table using AWS IAM, which permission must be granted?

Adynamodb:UpdateTimeToLive
Bdynamodb:EnableTTL
Cdynamodb:ModifyTableTTL
Ddynamodb:SetTTLAttribute
Attempts:
2 left
💡 Hint

Check the exact IAM action name for TTL updates.

❓ Architecture
advanced
2:00remaining
How does TTL impact read capacity and storage costs in DynamoDB?

Consider a DynamoDB table with TTL enabled. How does TTL affect read capacity units (RCUs) and storage costs over time?

ATTL reduces both storage costs and RCUs immediately after expiration.
BTTL increases RCUs because it triggers additional read operations for expired items.
CTTL reduces storage costs by deleting expired items, but does not reduce RCUs since expired items are still read until deleted.
DTTL has no effect on storage costs or RCUs.
Attempts:
2 left
💡 Hint

Think about when items are actually removed and how reads behave before deletion.

✅ Best Practice
expert
2:00remaining
What is the recommended approach to handle TTL attribute updates for item renewal?

You want to extend the life of an item in a DynamoDB table with TTL enabled by updating its expiration time. What is the best practice to update the TTL attribute?

ADelete the item and recreate it with a new TTL attribute value.
BLeave the TTL attribute unchanged; DynamoDB automatically extends TTL on item access.
CSet the TTL attribute to null to disable expiration, then set it again to a new timestamp.
DUpdate the TTL attribute with a new future Unix epoch time using an atomic update operation.
Attempts:
2 left
💡 Hint

Consider how to safely change the expiration time without losing the item.

Practice

(1/5)
1. What is the main purpose of Time to Live (TTL) in AWS DynamoDB?
easy
A. Backup data to another region
B. Encrypt data at rest for security
C. Automatically delete expired items to save storage space
D. Increase read capacity for faster queries

Solution

  1. Step 1: Understand TTL function

    TTL is designed to remove items automatically after a set expiration time.
  2. Step 2: Identify the main benefit

    This automatic deletion helps save storage space and reduces manual cleanup.
  3. Final Answer:

    Automatically delete expired items to save storage space -> Option C
  4. Quick Check:

    TTL purpose = automatic deletion [OK]
Hint: TTL deletes expired data automatically to save space [OK]
Common Mistakes:
  • Confusing TTL with encryption
  • Thinking TTL backs up data
  • Assuming TTL improves query speed
2. Which attribute type must the TTL attribute have in DynamoDB to enable expiration?
easy
A. Number representing Unix epoch time in seconds
B. Binary data with expiration timestamp
C. Boolean indicating expired or not
D. String containing date in ISO format

Solution

  1. Step 1: Check TTL attribute requirements

    DynamoDB TTL requires a Number attribute representing expiration time as Unix epoch seconds.
  2. Step 2: Eliminate other types

    String, Boolean, or Binary types are not valid for TTL expiration timestamps.
  3. Final Answer:

    Number representing Unix epoch time in seconds -> Option A
  4. Quick Check:

    TTL attribute = Number (epoch seconds) [OK]
Hint: TTL attribute must be a number with epoch seconds [OK]
Common Mistakes:
  • Using string dates instead of numbers
  • Setting TTL attribute as Boolean
  • Trying to use binary data for TTL
3. Given this DynamoDB item with TTL attribute expireAt: 1700000000 (Unix epoch seconds), what happens when current time is 1700000001?
medium
A. Item remains until manually deleted
B. Item's TTL attribute is reset to current time
C. Item is archived to S3 automatically
D. Item is immediately deleted by DynamoDB TTL process

Solution

  1. Step 1: Compare current time with TTL value

    The current time (1700000001) is greater than the TTL attribute (1700000000), so the item is expired.
  2. Step 2: Understand TTL behavior on expiration

    DynamoDB TTL automatically deletes expired items shortly after expiration time passes.
  3. Final Answer:

    Item is immediately deleted by DynamoDB TTL process -> Option D
  4. Quick Check:

    Current time > TTL = item deleted [OK]
Hint: Item deletes soon after TTL time passes [OK]
Common Mistakes:
  • Thinking TTL deletes instantly at exact second
  • Assuming manual deletion is needed
  • Believing TTL archives data instead of deleting
4. You enabled TTL on attribute expiry but items are not deleting after expiration. What is the most likely cause?
medium
A. DynamoDB table is in a different region
B. TTL attribute expiry is missing or has wrong data type
C. TTL only works on primary key attributes
D. TTL requires manual activation every 24 hours

Solution

  1. Step 1: Check TTL attribute correctness

    If the TTL attribute is missing or not a Number with epoch seconds, TTL won't delete items.
  2. Step 2: Verify other options

    TTL works regardless of region, does not require manual activation, and does not need to be primary key.
  3. Final Answer:

    TTL attribute expiry is missing or has wrong data type -> Option B
  4. Quick Check:

    Wrong TTL attribute = no deletion [OK]
Hint: TTL attribute must exist and be correct type [OK]
Common Mistakes:
  • Thinking TTL depends on table region
  • Believing TTL needs manual daily activation
  • Assuming TTL attribute must be primary key
5. You want to store session data that expires exactly 30 minutes after creation using DynamoDB TTL. Which approach correctly sets the TTL attribute?
hard
A. Set TTL attribute to current Unix epoch time in seconds plus 1800 seconds
B. Set TTL attribute to current time as ISO string plus 30 minutes
C. Set TTL attribute to Boolean true when session expires
D. Set TTL attribute to current Unix epoch time in milliseconds plus 1800000

Solution

  1. Step 1: Calculate TTL value correctly

    TTL attribute must be a Number in seconds, so add 1800 seconds (30 minutes) to current epoch seconds.
  2. Step 2: Eliminate incorrect formats

    ISO strings, Booleans, or milliseconds are invalid for TTL attribute in DynamoDB.
  3. Final Answer:

    Set TTL attribute to current Unix epoch time in seconds plus 1800 seconds -> Option A
  4. Quick Check:

    TTL = epoch seconds + 1800 [OK]
Hint: TTL value = current epoch seconds + 1800 for 30 minutes [OK]
Common Mistakes:
  • Using ISO date strings instead of epoch seconds
  • Using milliseconds instead of seconds
  • Setting TTL as Boolean instead of number
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard