Sairam Ravuri
Sairam Ravuri

Reputation: 27

Changing allotted values on parameters based on previously selected values on the parameters CloudFormation

I am making a CloudFormation template. I have a situation in which I want to change the parameters allotted values dynamically based on previously selected parameter values.

For example:

If parameter1 allotted values are True and False

parameter2 allotted values are 1,2,3, and 4.

If parameter1 is chosen True then parameter2 allotted values are 1,2,3, and 4 but if parameter1 is chosen False then parameter2 allotted values are 1 and 2.

I want a solution where the allotted values change automatically when the parameter1 is chosen False.

How to do this in CloudFormation?

Thanks in advance.

Upvotes: 0

Views: 805

Answers (2)

kgiannakakis
kgiannakakis

Reputation: 104188

You could perhaps use Conditions and Conditions Functions:

Parameters:
  MyParam:
    Default: false
    Type: String
    AllowedValues: [true, false]
Conditions:
  MyParamTrue: !Equals 
    - !Ref MyParam
    - true

Then inside resources:

Attribute: Fn::If: [MyParamTrue, [1,2,3], [1,2]]

Upvotes: 1

Paolo
Paolo

Reputation: 26094

No, that's not possible. CloudFormation parameters are static and you can't modify the behavior of a parameter based on another parameter.

Upvotes: 2

Related Questions