首页 > 解决方案 > CloudFormation 为参数指定 None 值

问题描述

我正在编写一个 cloudformation 模板,并有一个参数来获取 AWS 资源的一组配置值。NoneAWS 文档中指定的值之一。但是,当我输入nullcloudformation 时,堆栈失败并显示:

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

例如,为弹性 beanstalk 设置许多配置之一,默认为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

如何使用该None值作为参数的选项之一?

标签: amazon-web-servicesamazon-cloudformation

解决方案


这在 AWS 上被记录为伪参数。

使用AWS::NoValue设置 cloudformation 模板的 None 值。


推荐阅读