0
0
DynamoDBquery~30 mins

TTL attribute setup in DynamoDB - Mini Project: Build & Apply

Choose your learning style9 modes available
TTL Attribute Setup in DynamoDB
📖 Scenario: You are managing a DynamoDB table that stores user session data. To keep the table clean and efficient, you want to automatically delete expired sessions using DynamoDB's Time To Live (TTL) feature.
🎯 Goal: Set up the TTL attribute on the DynamoDB table to automatically remove expired session items.
📋 What You'll Learn
Create a DynamoDB table named UserSessions with a primary key SessionId (string).
Add an attribute called ExpirationTime to store the TTL timestamp.
Enable TTL on the UserSessions table using the ExpirationTime attribute.
💡 Why This Matters
🌍 Real World
Many applications store temporary data like user sessions or cache entries that should be automatically removed after some time to save storage and improve performance.
💼 Career
Understanding TTL setup in DynamoDB is important for backend developers and cloud engineers to manage data lifecycle and optimize database costs.
Progress0 / 4 steps
1
Create the DynamoDB table with primary key
Create a DynamoDB table named UserSessions with a primary key called SessionId of type string.
DynamoDB
Need a hint?

Use the AWS CLI create-table command with --table-name UserSessions and define SessionId as the HASH key of type string.

2
Add the TTL attribute to the table items
Add an attribute called ExpirationTime to your session items. This attribute will store the expiration timestamp as a number (Unix epoch time).
DynamoDB
Need a hint?

Use put-item to add a session with ExpirationTime as a number representing the Unix timestamp.

3
Enable TTL on the table using the ExpirationTime attribute
Enable TTL on the UserSessions table by specifying the TTL attribute name as ExpirationTime using the AWS CLI.
DynamoDB
Need a hint?

Use the AWS CLI update-time-to-live command with Enabled=true and AttributeName=ExpirationTime.

4
Verify TTL configuration on the table
Verify that TTL is enabled on the UserSessions table and the TTL attribute is set to ExpirationTime using the AWS CLI.
DynamoDB
Need a hint?

Use the AWS CLI describe-time-to-live command to check the TTL status on the table.