AWS Cloudformation parameter dependency

后端 未结 3 1017
天命终不由人
天命终不由人 2021-02-20 10:53

I\'m trying to do the following:

\"Parameters\": {
    \"InterfaceMode\" : {
        \"Description\": \"Configure instance to run in onearm or inline mode\",
           


        
相关标签:
3条回答
  • 2021-02-20 11:37

    I've been looking for this type of conditional parameter as well and as far as I can tell it doesn't exist. The closest you can come is an AWS Condition.

    http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html

    This will allow you to define conditions that evaluate to true or false based on input parameters that you can then use along with Fn:If statements to inject different values into resources.

    So for your above scenario you may want to default the value to a known subnet id, but use Conditions to ignore this value if not needed. Unfortunately this falls a bit short if you are trying to use the same CloudFormation template across different VPCs as the default subnet wouldn't exist.

    0 讨论(0)
  • 2021-02-20 11:40

    I do not think there is a good solution to your problem. One thing that you could try is to use AWS::NoValue as default default value, but I doubt it will work.

    0 讨论(0)
  • 2021-02-20 11:43

    Unfortunately, if you want a Parameter to be optional, you can not use any of the AWS-specific parameter types (i.e. AWS::*). None of your hoped-for workarounds will work, either. I'd recommend a type String with an AllowedPattern set to something like ^(subnet-[0-9a-fA-F]{8})?$, but this will not meet your requirement of making the drop-down prepopulated with existing subnet values.

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