0
0
DynamoDBquery~10 mins

TTL use cases (sessions, logs, cache) in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the TTL attribute name for a DynamoDB table.

DynamoDB
aws dynamodb update-time-to-live --table-name UserSessions --time-to-live-specification Enabled=true, AttributeName=[1]
Drag options to blanks, or click blank then click option'
AExpirationTime
BTTL
CDeleteAt
DExpireAt
Attempts:
3 left
💡 Hint
Common Mistakes
Using attribute names that are not configured as TTL attribute in the table.
Confusing TTL attribute name with other attribute names.
2fill in blank
medium

Complete the code to insert a session item with TTL set to expire in 1 hour.

DynamoDB
aws dynamodb put-item --table-name UserSessions --item '{"SessionId": {"S": "abc123"}, "UserId": {"S": "user1"}, "TTL": {"N": "[1]"}}'
Drag options to blanks, or click blank then click option'
A1672531200
B1672527600
C1672534800
D1672538400
Attempts:
3 left
💡 Hint
Common Mistakes
Using TTL as a date string instead of Unix timestamp.
Setting TTL to a past timestamp.
3fill in blank
hard

Fix the error in the TTL attribute type for a log entry.

DynamoDB
aws dynamodb put-item --table-name Logs --item '{"LogId": {"S": "log001"}, "Message": {"S": "Error occurred"}, "TTL": {"[1]": "1672534800"}}'
Drag options to blanks, or click blank then click option'
AN
BS
CBOOL
DM
Attempts:
3 left
💡 Hint
Common Mistakes
Using string type for TTL value.
Using boolean or map types for TTL.
4fill in blank
hard

Fill both blanks to create a cache item with TTL set to expire after 10 minutes.

DynamoDB
aws dynamodb put-item --table-name Cache --item '{"CacheKey": {"S": "user_profile_123"}, "Data": {"S": "[1]"}, "TTL": {"N": "[2]"}}'
Drag options to blanks, or click blank then click option'
A{"name":"John"}
B1672535400
C1672534800
D{"name":"Jane"}
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect TTL timestamp.
Using invalid JSON string for cache data.
5fill in blank
hard

Fill all three blanks to query expired sessions and delete them.

DynamoDB
aws dynamodb scan --table-name UserSessions --filter-expression "[1] < :now" --expression-attribute-values '{":now": {"[2]": "[3]"}}'
Drag options to blanks, or click blank then click option'
ATTL
BN
C1672534800
DS
Attempts:
3 left
💡 Hint
Common Mistakes
Using string type for timestamp in expression attribute values.
Filtering on wrong attribute name.