我想通過CloudFormation爲我的新創建的表啓用TTL。我試過以下無濟於事:CloudFormation - 爲DynamoDB創建TTL表創建表
{
"Resources" : {
"mytable" : {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"TableName" : "my_table",
"ProvisionedThroughput" : {"ReadCapacityUnits" : 1, "WriteCapacityUnits" : 5},
"KeySchema" :
[
{"AttributeName" : "user_email", "KeyType" : "HASH"},
{"AttributeName" : "datetime", "KeyType" : "RANGE"}
],
"AttributeDefinitions": [
{"AttributeName" : "user_email", "AttributeType" : "S"},
{"AttributeName" : "datetime", "AttributeType" : "S"}
],
"TimeToLiveDescription": {
"AttributeName": "expire_at",
"TimeToLiveStatus": "ENABLED"
}
}
}
}
我用了TimeToLiveDescription,這是我從this doc獲得。
試圖創建堆棧給了我以下錯誤:
Encountered unsupported property TimeToLiveDescription
我可以執行CLI在模板的命令,即使我不是啓動一個新的EC2實例? –
需要在某種類型的主機或環境上執行CLI命令 - 因爲據我所知,另一種替代方案是通過添加執行cli命令的Lambda函數。你可以在這裏閱讀更多關於它的信息:https://alestic.com/2016/11/aws-lambda-awscli/ 我不知道任何其他方法。 – ivanji
我知道的唯一其他方法(不在模板內)將使用像Jenkis這樣的構建服務/服務器來啓動Cloudformation Stack,然後從構建服務器執行必要的aws命令。 (你需要在服務器上安裝AWS cli等)。 – ivanji