CloudFormation: Create resources if they do not exist, but do not delete them

后端 未结 1 899
春和景丽
春和景丽 2021-01-02 21:33

I have the following CloudFormation template. (It is based off default the template created for running C# Web API in AWS Lambda, but that may not be relevant.)

It c

相关标签:
1条回答
  • 2021-01-02 22:27

    When you are updating your existing stack, do not change the parameters. So even when you are updating your stack, set ShouldCreateTable to true.

    Yes, it seems counter-intuitive when updating your stack to say "Create a table", when a table already exists, but you need to do that.

    The reason is this:

    1. When the stack is created, you set ShouldCreateTable to true, and the template applies it's conditional logic and creates the table as it's own managed resource.
    2. When the stack is updated, you set ShouldCreateTable to false, and the template applies it's conditional logic and determines you no longer need the managed table because you're providing your own now. The resource should be deleted. It does not recognize that the table is the same.

    When using your template, only say ShouldCreateTable == false if you are providing your own table that you created.

    0 讨论(0)
提交回复
热议问题