0
0
AWScloud~30 mins

Time to live (TTL) for expiration in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Time to live (TTL) for expiration
📖 Scenario: You are managing a cloud database where data should automatically expire after a certain time to save space and keep information fresh.Imagine a library where books are borrowed and must be returned after a fixed period. Similarly, data entries will have a 'time to live' (TTL) that tells the system when to delete them.
🎯 Goal: Create a DynamoDB table with a TTL attribute that automatically deletes expired items.
📋 What You'll Learn
Create a DynamoDB table named LibraryBooks with a primary key BookID of type string.
Add a TTL attribute named ExpirationTime to the table configuration.
Set the TTL attribute to enable automatic expiration of items.
Use AWS CloudFormation syntax for the configuration.
💡 Why This Matters
🌍 Real World
TTL is used in cloud databases to automatically remove outdated data, saving storage and improving performance.
💼 Career
Understanding TTL configuration is important for cloud engineers and architects managing scalable, cost-efficient databases.
Progress0 / 4 steps
1
Create DynamoDB table resource
Create a DynamoDB table resource named LibraryBooks with a primary key attribute BookID of type String in AWS CloudFormation YAML syntax.
AWS
Need a hint?

Define the DynamoDB table with Type: AWS::DynamoDB::Table. Use AttributeDefinitions and KeySchema to set the primary key.

2
Add TTL attribute name configuration
Add a TimeToLiveSpecification property to the LibraryBooks resource with AttributeName set to ExpirationTime.
AWS
Need a hint?

Use TimeToLiveSpecification inside Properties to specify the TTL attribute name.

3
Enable TTL for the attribute
Add Enabled: true inside the TimeToLiveSpecification property to activate TTL on the ExpirationTime attribute.
AWS
Need a hint?

Set Enabled to true to turn on TTL for the attribute.

4
Complete the CloudFormation template
Add the ExpirationTime attribute to AttributeDefinitions with type Number to store the TTL timestamp.
AWS
Need a hint?

TTL attribute must be defined as a Number type in AttributeDefinitions.