问题描述
示例云形成/无服务器
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
这就是我到目前为止所拥有的:
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 \
我想要/需要的是在我的aws cli命令中添加一个TTL / TimetoLive Spec。
人,请帮我谢谢!!
解决方法
首先执行此操作:-
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
然后启用ttl:
aws dynamodb update-time-to-live --table-name sample-tb-with-ttl \
--time-to-live-specification Enabled=true,AttributeName=expiration