简体   繁体   English

AWS Cloud Formation 在创建之前删除资源

[英]AWS Cloud formation delete resource before creating

I tried to write cloud formation script for creating dynamodb.我尝试编写用于创建 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.?有没有办法在创建之前删除资源。?

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, eg: Ref "terminationLettersDynamodb"省略 TableName 时,您可以使用Ref内在 function 引用堆栈中其他地方动态创建的表名,例如:Ref "terminationLettersDynamodb"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM