Reputation: 892
I tried to write cloud formation script for creating dynamodb. When i execute script its getting error already exists in stack.
This is my template.
AWSTemplateFormatVersion: "2010-09-09"
Resources:
terminationLettersDynamodb:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
- AttributeName: schemeId
AttributeType: S
KeySchema:
- AttributeName: schemeId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: "terminationLetters"
Is there any way to delete resource before creating.?
Upvotes: 0
Views: 603
Reputation: 799
You should avoid using hardcoded table names. If you specify a name, you cannot perform updates that require replacement of this resource.
When leaving out the TableName, you can reference the dynamically created table name elsewhere in your stack with the Ref
intrinsic function, e.g.: Ref "terminationLettersDynamodb"
Upvotes: 2