Bal*_*i V 8 cloud amazon-web-services aws-cloudformation aws-lambda
我正在为 lambda 创建一个云层。我想要一个创建 lambda 的通用 lambda 脚本。我在从外部注入“环境”参数时遇到问题。
我想将键值对对象作为参数传递。有人能告诉我怎么做吗。我在下面强调了它
{
"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, ... ]
}
}
Run Code Online (Sandbox Code Playgroud)
Ale*_*nko 11
为此,cloudformation 模板中有一个特殊部分 - Parameters
"Parameters" : {
"MyVariable" : {
"Type" : "String",
"Default" : "test",
"AllowedValues" : ["test", "non-test"],
"Description" : "My very important variable."
}
}
Run Code Online (Sandbox Code Playgroud)
然后在Function
声明中使用这些参数:
"Environment":{
"Variables":{
"SomeVariable":{
"Ref":"MyVariable"
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后在从 cloudformation 模板创建堆栈时传递此参数块的值:
aws cloudformation create-stack --stack-name S1 --template-body example template --parameters ParameterKey=MyVariable,ParameterValue=myValue
Run Code Online (Sandbox Code Playgroud)
更多信息 -在这里
归档时间: |
|
查看次数: |
18739 次 |
最近记录: |