Complete the code to set the TTL attribute name for a DynamoDB table.
aws dynamodb update-time-to-live --table-name UserSessions --time-to-live-specification Enabled=true, AttributeName=[1]The TTL attribute name in DynamoDB is commonly set as TTL to indicate the expiration timestamp.
Complete the code to insert a session item with TTL set to expire in 1 hour.
aws dynamodb put-item --table-name UserSessions --item '{"SessionId": {"S": "abc123"}, "UserId": {"S": "user1"}, "TTL": {"N": "[1]"}}'
The TTL value must be a Unix epoch timestamp in seconds. If the current time is 1672531200, adding 3600 seconds (1 hour) results in 1672534800.
Fix the error in the TTL attribute type for a log entry.
aws dynamodb put-item --table-name Logs --item '{"LogId": {"S": "log001"}, "Message": {"S": "Error occurred"}, "TTL": {"[1]": "1672534800"}}'
The TTL attribute must be a number type (N) representing the Unix timestamp in seconds.
Fill both blanks to create a cache item with TTL set to expire after 10 minutes.
aws dynamodb put-item --table-name Cache --item '{"CacheKey": {"S": "user_profile_123"}, "Data": {"S": "[1]"}, "TTL": {"N": "[2]"}}'
The cache data is a JSON string representing user info. TTL is set to a Unix timestamp 10 minutes (600 seconds) after 1672534800, which is 1672535400.
Fill all three blanks to query expired sessions and delete them.
aws dynamodb scan --table-name UserSessions --filter-expression "[1] < :now" --expression-attribute-values '{":now": {"[2]": "[3]"}}'
The filter expression checks if the TTL attribute is less than the current Unix timestamp (1672534800). The attribute value type is number (N).