Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a DeletionPolicy from Parameters in CloudFormation

I am trying to adapt my DeletionPolicy in my CloudFormation template:

        "DeletionPolicy":{
            "Fn::If":[
                "ShouldRetain",
                "Retain",
                "Delete"
            ]
        }

Though I get:

Template format error: Every DeletionPolicy member must be a string.
like image 754
AsTeR Avatar asked Apr 21 '16 12:04

AsTeR


People also ask

How do you reference parameters in CloudFormation?

You use the Ref intrinsic function to reference a parameter, and AWS CloudFormation uses the parameter's value to provision the stack. You can reference parameters from the Resources and Outputs sections of the same template.

How do you reference existing resources in CloudFormation?

To import existing resources into a CloudFormation stack, you need to provide: A template that describes the entire stack, including both the resources to import and (for existing stacks) the resources that are already part of the stack. Each resource to import must have a DeletionPolicy attribute in the template.

How do I change parameters in CloudFormation stack?

To update a AWS CloudFormation stack (console)In the AWS CloudFormation console , from the list of stacks, select the running stack that you want to update. In the stack details pane, choose Update. If you haven't modified the stack template, select Use current template, and then choose Next.

How do you create a changeset in CloudFormation?

To create a change set (console)In the AWS CloudFormation console , in Stacks, choose the running stack for which you want to create a change set. In the stack details pane, choose Stack actions, and then choose Create change set for current stack.


1 Answers

Unfortunately, the "DeletionPolicy" parameter must take a string literal only. Anything that resolve to a string such as from mapping or parameters is not possible. This is limitation from AWS.

like image 131
Calvin Boey Avatar answered Sep 21 '22 18:09

Calvin Boey