gpt4 book ai didi

amazon-web-services - CloudFormation,将 List 参数作为逗号分隔的字符串传递?

转载 作者:行者123 更新时间:2023-12-03 07:25:59 30 4
gpt4 key购买 nike

如何传递 List<AWS::EC2::Subnet::Id> 类型的参数作为逗号分隔的字符串?

我有以下模板:

{
"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 Value of property Value must be of type String

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

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

结果

Template validation error: Template Error: Encountered unsupported function: Fn:Join Supported functions are: [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]

最佳答案

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

关于amazon-web-services - CloudFormation,将 List<AWS::EC2::Subnet::Id> 参数作为逗号分隔的字符串传递?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39770088/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com