Complete the code to enable automatic expiration on a DynamoDB table by specifying the TTL attribute.
aws dynamodb update-time-to-live --table-name MyTable --time-to-live-specification Enabled=true, AttributeName=[1]The TTL attribute must be named exactly as specified when enabling automatic expiration. 'TTL' is the common attribute name used for this purpose.
Complete the code to query items that have not yet expired by filtering on the TTL attribute.
SELECT * FROM MyTable WHERE [1] > unixTimestamp(CURRENT_TIMESTAMP)To find items that are still valid, you compare the TTL attribute to the current time. The TTL attribute is used for this purpose.
Fix the error in the TTL configuration command by selecting the correct option for enabling TTL.
aws dynamodb update-time-to-live --table-name MyTable --time-to-live-specification Enabled=[1], AttributeName=TTLThe 'Enabled' field expects a lowercase boolean string 'true' without quotes in the AWS CLI command.
Fill both blanks to create a DynamoDB table with TTL enabled on the 'TTL' attribute.
aws dynamodb create-table --table-name MyTable --attribute-definitions AttributeName=ID,AttributeType=S --key-schema AttributeName=ID,KeyType=HASH --billing-mode PAY_PER_REQUEST --[1] Enabled=true,AttributeName=[2]
The correct parameter to enable TTL is 'time-to-live-specification' and the attribute name is 'ttl'.
Fill all three blanks to write a DynamoDB expression that deletes expired items based on the TTL attribute.
DELETE FROM MyTable WHERE [1] <= unixTimestamp([2]) AND [3] = true
The TTL attribute stores the expiration time. We compare it to the current timestamp. The 'isExpired' flag can be used to mark expired items.