I declared a DynamoDB table in my Resources section, but for some reason when I try to deploy it, it always tries to recreate my DynamoDB table, even though the status is set to Retain:
resources:
Resources:
Table:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: FIELD1
AttributeType: S
-
AttributeName: FIELD2
AttributeType: N
KeySchema:
-
AttributeName: FIELD1
KeyType: HASH
-
AttributeName: FIELD2
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: ${self:provider.environment.DYNAMODB_TABLE}
I checked the output of CloudFormation and this is what I get:
{
"StackId": "STACKID",
"EventId": "Table-CREATE_FAILED-2018-01-04T10:11:50.751Z",
"ResourceStatus": "CREATE_FAILED",
"ResourceType": "AWS::DynamoDB::Table",
"Timestamp": "2018-01-04T10:11:50.751Z",
"ResourceStatusReason": "TABLE already exists",
"StackName": "STACKNAME",
"ResourceProperties": "{\"TableName\":\"TABLE\",\"AttributeDefinitions\":[{\"AttributeType\":\"S\",\"AttributeName\":\"FIELD1\"},{\"AttributeType\":\"N\",\"AttributeName\":\"TIMESTAMP\"}],\"ProvisionedThroughput\":{\"WriteCapacityUnits\":\"5\",\"ReadCapacityUnits\":\"5\"},\"KeySchema\":[{\"KeyType\":\"HASH\",\"AttributeName\":\"FIELD1\"},{\"KeyType\":\"FIELD2\",\"AttributeName\":\"TIMESTAMP\"}]}\n",
"PhysicalResourceId": "",
"LogicalResourceId": "TABLE"
}
Any idea what the problem is? If I remove that table manually and run sls deploy
, it works fine. If I run sls deploy
again, I get that error message.