【问题标题】:CloudFormation, passing a List<AWS::EC2::Subnet::Id> parameter as a comma separated string?CloudFormation,将 List<AWS::EC2::Subnet::Id> 参数作为逗号分隔的字符串传递?
【发布时间】:2016-09-29 20:50:30
【问题描述】:

如何将List&lt;AWS::EC2::Subnet::Id&gt; 类型的参数作为逗号分隔的字符串传递?

我有以下模板:

{
  "AWSTemplateFormatVersion": "2010-09-09",

  "Parameters": {
    "PrivateSubnets": {
      "Description": "The private subnets in which Beanstalk EC2 instances will created",
      "Type": "List<AWS::EC2::Subnet::Id>"
    },
    "PublicSubnets": {
      "Description": "The public subnets in which the Beanstalk ELBs will be created",
      "Type": "List<AWS::EC2::Subnet::Id>"
    }
  },

  "Resources": {
    "MyApp": {
      "Type": "AWS::ElasticBeanstalk::Application",
      "Properties": {
        "ApplicationName": "MyApp",
        "Description": "AWS Elastic Beanstalk Application"
      }
    },

    "ConfigTemplate": {
      "Type": "AWS::ElasticBeanstalk::ConfigurationTemplate",
      "Properties": {
        "ApplicationName": { "Ref": "MyApp" },
        "Description": "Microsite Beanstalk config template",
        "OptionSettings": [
          { "Namespace": "aws:ec2:vpc", "OptionName": "ELBSubnets", "Value": { "Ref": "PublicSubnets" } },
          { "Namespace": "aws:ec2:vpc", "OptionName": "Subnets", "Value": { "Ref": "PrivateSubnets"} }
        ],
        "SolutionStackName": "64bit Amazon Linux 2016.03 v2.1.7 running PHP 5.6"
      }
    }
  }
}

当我尝试创建堆栈时,我收到以下错误:

CREATE_FAILED AWS::ElasticBeanstalk::ConfigurationTemplate ConfigTemplate 属性值的值必须是字符串类型

尝试使用Fn:Join 将私有子网和公共子网的内容写入逗号分隔的字符串,例如

{ "Namespace": "aws:ec2:vpc", "OptionName": "ELBSubnets", "Value": { "Fn:Join": [",", { "Ref": "PublicSubnets" }]} },
{ "Namespace": "aws:ec2:vpc", "OptionName": "Subnets", "Value": { "Fn:Join": [",", { "Ref": "PrivateSubnets"}]} },

结果

模板验证错误:模板错误:遇到不支持的函数:Fn:Join 支持的函数有:[Fn::Base64, Fn::GetAtt, Fn::GetAZs, Fn::ImportValue, Fn::Join, Fn:: FindInMap, Fn::Select, Ref, Fn::Equals, Fn::If, Fn::Not, Condition, Fn::And, Fn::Or, Fn::Contains, Fn::EachMemberEquals, Fn::EachMemberIn , Fn::ValueOf, Fn::ValueOfAll, Fn::RefAll, Fn::Sub]

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk amazon-cloudformation


    【解决方案1】:

    根据http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-ec2vpc,您需要提供一个逗号分隔的列表。所以使用Fn::Join(注意两个冒号)

    【讨论】:

    • 谢谢。愚蠢的错字,我知道为什么我忽略了它,尤其是在再次阅读错误消息时。
    猜你喜欢
    • 2017-09-09
    • 2021-07-24
    • 2016-03-23
    • 1970-01-01
    • 2014-10-12
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多