amazon-web-services - aws cli 创建一个具有生存时间规范的表
问题描述
我想执行一个 cli 命令来创建一个带有 TTL 的表。
示例云形成/无服务器
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 规范。
大佬们帮帮我谢谢!!
解决方案
首先这样做:-
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
推荐阅读
- c# - 更新组中的多个设置
- javascript - 传递带有事件和参数的函数,在 React 中没有无限循环
- java - 自定义注释的Spring AOP切入点不起作用内部静态类
- python - 从 C 调用 python 函数时出错
- r - ggplot add geom_path 具有不同的颜色美学//错误:错误:手动比例中的值不足
- postgresql - Dockerising Elixir/Phoenix 应用程序:(Postgrex.Error) FATAL 28P01 (invalid_password) 用户“postgres”的密码验证失败
- ios - 'AFHTTPSessionManager' 没有可见的@interface 声明选择器'dataTaskWithRequest:completionHandler:'
- keyword - ECL 中的 LEFT 和 RIGHT 关键字
- sql - 如何使用 PostgreSQL 中的表中的 IN 获取唯一的最新项目
- python - 是否可以连接两个图表,一个用 matplotlib.pyplot 绘制,另一个用 mplfinance 绘制到同一个图中。例如; 相同的图像