I would like to perform a cli command which creates a table with TTL.
a sample cloud formation/ serverless
SampleTBWithTTL:
Type: AWS::DynamoDB::Table
Properties:
TableName: SampleTBWithTTL
AttributeDefinitions:
- AttributeName: "user_id"
AttributeType: "N"
- AttributeName: "name"
AttributeType: "S"
KeySchema:
- AttributeName: "user_id"
KeyType: "HASH"
- AttributeName: "name"
KeyType: "RANGE"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TimeToLiveSpecification:
AttributeName: expiration
Enabled: true
so this is what I have so far :
aws dynamodb create-table --table-name sample-tb-with-ttl \
--attribute-definitions AttributeName=user_id,AttributeType=N \
AttributeName=name,AttributeType=S \
--key-schema AttributeName=user_id,KeyType=HASH \
AttributeName=name,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
and what I want/need is to add a TTL/TimeToLive Spec in my aws cli command.
Guys Please help me thanks!!
First do this:-
aws dynamodb create-table --table-name sample-tb-with-ttl \
--attribute-definitions AttributeName=user_id,AttributeType=N \
AttributeName=name,AttributeType=S \
--key-schema AttributeName=user_id,KeyType=HASH \
AttributeName=name,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Then enable ttl :
aws dynamodb update-time-to-live --table-name sample-tb-with-ttl \
--time-to-live-specification Enabled=true,AttributeName=expiration