我正在为lambda创建云层。我想要一个创建lambda的通用lambda脚本。我从外部注入“ Environment”参数时遇到问题。
我想将键值对对象作为参数传递。有人能告诉我怎么做吗。我在下面突出显示了
{
"Variables" : **{ String:String, ... }**
}
{
"Type" : "AWS::Lambda::Function",
"Properties" : {
"Code" : Code,
"DeadLetterConfig" : DeadLetterConfig,
"Description" : String,
"Environment" : Environment,
"FunctionName" : String,
"Handler" : String,
"KmsKeyArn" : String,
"MemorySize" : Integer,
"ReservedConcurrentExecutions" : Integer,
"Role" : String,
"Runtime" : String,
"Timeout" : Integer,
"TracingConfig" : TracingConfig,
"VpcConfig" : VPCConfig,
"Tags" : [ Resource Tag, ... ]
}
}
答案 0 :(得分:0)
为此,cloudformation模板中有一个特殊的部分-Parameters
"Parameters" : {
"MyVariable" : {
"Type" : "String",
"Default" : "test",
"AllowedValues" : ["test", "non-test"],
"Description" : "My very important variable."
}
}
然后在Function
声明中使用这些参数:
"Environment":{
"Variables":{
"SomeVariable":{
"Ref":"MyVariable"
}
}
}
然后从cloudformation模板创建堆栈时传递此Parameters块的值:
aws cloudformation create-stack --stack-name S1 --template-body example template --parameters ParameterKey=MyVariable,ParameterValue=myValue
更多信息-here
答案 1 :(得分:0)
“我想将键值对对象作为参数传递”
您不能将键值对作为参数传递给AWS CF模板。有关可接受的参数类型,请参见this