TTL stands for Time To Live. It is a feature that automatically deletes expired items from a DynamoDB table.
Click to reveal answer
beginner
How do you enable TTL on a DynamoDB table?
You enable TTL by specifying a TTL attribute name in the table settings. This attribute stores the expiration time as a Unix timestamp.
Click to reveal answer
beginner
What type of value should the TTL attribute hold?
The TTL attribute should hold a Unix epoch timestamp in seconds, indicating when the item should expire.
Click to reveal answer
intermediate
Does DynamoDB delete expired items immediately after the TTL timestamp?
No, DynamoDB deletes expired items within 48 hours after the expiration time. The deletion is eventually consistent.
Click to reveal answer
intermediate
Can you use TTL on any attribute in DynamoDB?
No, TTL must be enabled on a single attribute per table, and that attribute must contain the expiration timestamp.
Click to reveal answer
What data type should the TTL attribute in DynamoDB be?
AUnix timestamp in seconds
BBoolean true/false
CString containing a date
DISO 8601 formatted string
✗ Incorrect
The TTL attribute must be a Unix timestamp in seconds representing the expiration time.
When does DynamoDB remove expired items after the TTL timestamp?
AWithin 48 hours after expiration
BOnly when manually deleted
CAfter 7 days
DImmediately at the timestamp
✗ Incorrect
DynamoDB removes expired items within 48 hours after the TTL timestamp, not immediately.
How many TTL attributes can you enable per DynamoDB table?
ATwo
BOne
CUnlimited
DNone
✗ Incorrect
You can enable TTL on only one attribute per DynamoDB table.
What happens if the TTL attribute is missing or empty for an item?
AItem causes an error
BItem expires immediately
CItem is deleted after 24 hours
DItem never expires
✗ Incorrect
If the TTL attribute is missing or empty, the item does not expire.
Which of the following is required to enable TTL on a DynamoDB table?
ASet a read capacity unit
BCreate a global secondary index
CSpecify the TTL attribute name
DEnable encryption
✗ Incorrect
You must specify the TTL attribute name to enable TTL on a DynamoDB table.
Explain how to set up TTL on a DynamoDB table and what type of data the TTL attribute should contain.
Think about the attribute name and the format of the expiration time.
You got /4 concepts.
Describe what happens to items in DynamoDB after their TTL expiration time passes.
Consider the timing and consistency of the deletion process.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of setting a TTL attribute in a DynamoDB table?
easy
A. To increase the read capacity of the table
B. To encrypt data stored in the table
C. To create backups of the table data
D. To automatically delete expired items based on a timestamp
Solution
Step 1: Understand TTL functionality
TTL (Time To Live) is used to automatically remove items after a certain time.
Step 2: Identify the purpose in DynamoDB context
In DynamoDB, TTL deletes expired items to save storage and cost.
Final Answer:
To automatically delete expired items based on a timestamp -> Option D
Quick Check:
TTL = auto-delete expired items [OK]
Hint: TTL means auto-delete expired data by timestamp [OK]
Common Mistakes:
Confusing TTL with encryption
Thinking TTL increases capacity
Assuming TTL creates backups
2. Which of the following is the correct way to specify the TTL attribute in DynamoDB?
easy
A. Set a numeric attribute with Unix epoch time in seconds
B. Set a list attribute with expiration dates
C. Set a boolean attribute to true when item expires
D. Set a string attribute with date format 'YYYY-MM-DD'
Solution
Step 1: Recall TTL attribute data type
DynamoDB TTL requires a numeric attribute representing Unix epoch time in seconds.
Step 2: Evaluate options
Only Set a numeric attribute with Unix epoch time in seconds correctly uses numeric Unix epoch seconds for TTL.
Final Answer:
Set a numeric attribute with Unix epoch time in seconds -> Option A
Quick Check:
TTL attribute = numeric Unix epoch seconds [OK]
Hint: TTL attribute must be numeric Unix epoch seconds [OK]
Common Mistakes:
Using string date formats instead of numeric
Using boolean or list types for TTL
Not enabling TTL on the table after setting attribute
3. Given a DynamoDB item with attribute expireAt set to 1700000000 (Unix epoch seconds), and TTL enabled on expireAt, what happens when the current time is 1700000001?
medium
A. The item remains until manually deleted
B. The item is automatically deleted by DynamoDB
C. The item is archived automatically
D. The item is updated with a new TTL value
Solution
Step 1: Understand TTL expiration behavior
When current time exceeds the TTL timestamp, DynamoDB marks the item for deletion.
Step 2: Apply to given timestamp
Since current time 1700000001 > expireAt 1700000000, item is deleted automatically.
Final Answer:
The item is automatically deleted by DynamoDB -> Option B
Quick Check:
Current time > TTL timestamp = item deleted [OK]
Hint: Item deletes when current time passes TTL timestamp [OK]
Common Mistakes:
Thinking item stays until manual deletion
Assuming item is archived instead of deleted
Believing TTL updates item automatically
4. You set the TTL attribute to a string value like "2024-12-31" and enabled TTL on that attribute. What issue will you face?
medium
A. TTL will not delete expired items because attribute is not numeric
B. DynamoDB will throw a syntax error on enabling TTL
C. Items will be deleted immediately regardless of date
D. TTL will convert string to numeric automatically
Solution
Step 1: Check TTL attribute type requirement
TTL attribute must be numeric Unix epoch seconds, not string.
Step 2: Analyze effect of string value
DynamoDB ignores TTL deletion if attribute is not numeric, so items won't expire.
Final Answer:
TTL will not delete expired items because attribute is not numeric -> Option A
Quick Check:
Non-numeric TTL attribute = no deletion [OK]
Hint: TTL attribute must be numeric; strings cause no deletion [OK]
Common Mistakes:
Expecting DynamoDB to error on TTL enable
Assuming immediate deletion with wrong type
Believing automatic type conversion happens
5. You want to set up TTL on a DynamoDB table to delete items 7 days after creation. Which approach correctly sets the TTL attribute expireAt when inserting an item?
hard
A. Set expireAt to a boolean true after 7 days
B. Set expireAt to current date string plus 7 days in 'YYYY-MM-DD' format
C. Set expireAt to current Unix epoch seconds plus 604800 (7 days in seconds)
D. Set expireAt to the current Unix epoch seconds without adding days
Solution
Step 1: Calculate TTL timestamp for 7 days later
7 days = 7 * 24 * 60 * 60 = 604800 seconds; add to current Unix epoch seconds.
Step 2: Set TTL attribute correctly
Assign expireAt the numeric value of current time + 604800 seconds for proper TTL.
Final Answer:
Set expireAt to current Unix epoch seconds plus 604800 (7 days in seconds) -> Option C
Quick Check:
TTL timestamp = now + 7 days in seconds [OK]
Hint: Add 604800 seconds to now for 7-day TTL [OK]
Common Mistakes:
Using date strings instead of numeric timestamps
Setting TTL to current time without delay
Using boolean or other types for TTL
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.