Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation specify None value for parameter

I am writing a cloudformation template and have a parameter to take in a set of configuration values for AWS resources. One of the value is None as specified on the AWS documentation. However when I input null into the cloudformation, the stack fails with:

Template validation error: [/Parameters/.../AllowedValues/1] 'null' values are not allowed in templates.

For example setting one of the many configurations for elastic beanstalk which defaults to None:

Parameters:
  EC2KeyPairName:
    Description: EC2 key pair name for SSH access
    Type: AWS::EC2::KeyPair::KeyName
    Default: null

Resources:
  Type: AWS::ElasticBeanstalk::ConfigurationTemplate
    Properties:
      ApplicationName: !Ref Application
      SolutionStackName: !FindInMap [ StackMap, !Ref StackType, stackName ]
      OptionSettings:
        - Namespace: aws:autoscaling:launchconfiguration
          OptionName: EC2KeyName
          Value: !Ref EC2KeyPairName

How do I use the None value as one of the options for the parameter?

like image 442
hangc Avatar asked Jan 07 '19 05:01

hangc


People also ask

What is pseudo parameter in aws CloudFormation?

Pseudo parameters are parameters that are predefined by AWS CloudFormation. You don't declare them in your template. Use them the same way as you would a parameter, as the argument for the Ref function.

How do you reference a parameter 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.

What is FN :: if?

Fn::If. Returns one value if the specified condition evaluates to true and another value if the specified condition evaluates to false .

How do you add condition in CloudFormation?

Depending on the entity you want to conditionally create or configure, you must include statements in the following template sections: Parameters section. Define the inputs that you want your conditions to evaluate. The conditions evaluate to true or false based on the values of these input parameters.


1 Answers

This is documented as Pseudo parameters on AWS.

Using AWS::NoValue sets the None value for the cloudformation templates.

like image 70
hangc Avatar answered Nov 11 '22 19:11

hangc