Home > Net >  Changing allotted values on parameters based on previously selected values on the parameters CloudFo
Changing allotted values on parameters based on previously selected values on the parameters CloudFo

Time:12-07

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.

CodePudding user response:

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

CodePudding user response:

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]]
  • Related