我使用嵌套堆栈来创建电子束和应用程序stacks...And,我需要将子网列表传递给电子束和应用程序栈。
主要的json有以下代码..。
"Mappings":{
"params":{
"Subnets": {
"dev":[
"subnet-1”,
"subnet-2”
],
"test":[
"subnet-3”,
"subnet-4”,
"subnet-5”,
"subnet-6”
],
"prod":[
"subnet-7”,
"subnet-8”,
"subnet-9”
]
}
}
},
"Parameters":{
"Environment":{
"AllowedValues":[
"prod",
"preprod",
"dev"
],
"Default":"prod",
"Description":"What environment type is it (prod, preprod, test, dev)?",
"Type":"String"
}
},
Resources:{
"ELBStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": {
"Fn::Join":[
"",
[
"https://s3.amazonaws.com/",
"myS3bucket",
"/ELB.json"
]
]
},
"Parameters": {
"Environment":{"Ref":"Environment"},
"ELBSHORTNAME":{"Ref":"ELBSHORTNAME"},
"Subnets":{"Fn::FindInMap":[
"params",
"Subnets",
{
"Ref":"Environment"
}
]},
"S3Bucket":{"Ref":"S3Bucket"},
},
"TimeoutInMinutes": "60"
}
}现在,当我使用lambda或cloudformation运行这个json时,我在cloudformation下得到以下错误.
CREATE_FAILED AWS::CloudFormation::Stack ELBStack Value of property Parameters must be an object with String (or simple type) properties
using below lambda
import boto3
import time
date = time.strftime("%Y%m%d")
time = time.strftime("%H%M%S")
stackname = 'FulfillSNSELB'
client = boto3.client('cloudformation')
response = client.create_stack(
StackName= (stackname + '-' + date + '-' + time),
TemplateURL='https://s3.amazonaws.com/****/**/myapp.json',
Parameters=[
{
'ParameterKey': 'Environment',
'ParameterValue': 'dev',
'UsePreviousValue': False
}]
)
def lambda_handler(event, context):
return(response)发布于 2016-03-30 23:51:44
您的JSON格式不太好。通过aws cloudformation validate-template (甚至jsonlint.com)运行JSON会很快发现几个基本的语法错误:
Resources:{要求密钥被引号包围:"Resources": {"subnet-1”,,需要用标准的ASCII引号:"subnet-1",替换。"S3Object: {"Ref: "S3Bucket"},"中的"S3Object: {"Ref: "S3Bucket"},"对象在其最后一个需要删除的元素之后有一个后缀逗号:"S3Object: {"Ref: "S3Bucket"}"发布于 2018-03-29 19:56:15
不能将列表传递给嵌套堆栈。您必须将项与内部函数加入连接起来,如下所示:!Join ["separator", [item1, item2, …]]。
在嵌套堆栈中,参数的类型需要是List<Type>。
https://stackoverflow.com/questions/36166012
复制相似问题