我有一个通过visual创建的无服务器项目,我正在寻找在cloudformation模板中设置特定lambda的maximumRetryAttempt。我看到了EventInvokeConfig,但是lambda函数名是自动生成的,并且与每个环境不同。我想知道是否有一个aws特定的参数来获得一个lambda函数名?
"EventInvokeConfig": {
"Type" : "AWS::Lambda::EventInvokeConfig",
"Properties" : {
"FunctionName" : "???",
"MaximumRetryAttempts" : 0,
"Qualifier" : "$LATEST"
}
}这是我的无服务器模板
{
"AWSTemplateFormatVersion":"2010-09-09",
"Transform":"AWS::Serverless-2016-10-31",
"Description":"An AWS Serverless Application that uses the ASP.NET Core framework running in Amazon Lambda.",
"Resources":{
"MyFunctionLambda":{
"Type":"AWS::Serverless::Function",
"Properties":{
"Handler":"MyPlatformServerless::MyPlatformServerless.Lambdas.MyFunctionLambda::FunctionHandler",
"Runtime":"dotnetcore2.1",
"CodeUri":"",
"Description":"Default function",
"MemorySize":512,
"Timeout":60,
"Role":null
}
}
}
}发布于 2020-04-06 02:36:52
您可以使用Ref固有函数。对于AWS::Serverless::Function类型的资源,返回的值是函数的名称。
这可以在模板中定义的其他资源中引用。对于EventInvokeConfig,模板看起来像
{
"AWSTemplateFormatVersion":"2010-09-09",
"Transform":"AWS::Serverless-2016-10-31",
"Description":"An AWS Serverless Application that uses the ASP.NET Core framework running in Amazon Lambda.",
"Resources":{
"MyFunctionLambda":{
"Type":"AWS::Serverless::Function",
"Properties":{
"Handler":"MyPlatformServerless::MyPlatformServerless.Lambdas.MyFunctionLambda::FunctionHandler",
"Runtime":"dotnetcore2.1",
"CodeUri":"",
"Description":"Default function",
"MemorySize":512,
"Timeout":60,
"Role":null
}
},
"EventInvokeConfig": {
"Type" : "AWS::Lambda::EventInvokeConfig",
"Properties" : {
"FunctionName" : { "Ref" : MyFunctionLambda },
"MaximumRetryAttempts" : 0,
"Qualifier" : "$LATEST"
}
}
}
}发布于 2021-07-17 05:40:30
您的问题可能已经解决,但您可以改进代码。在使用Serverless (SAM)时,可以在lambda资源属性中直接指定EventInvokeConfig,而不需要创建其他资源。请找到以下片段:
{
"AWSTemplateFormatVersion":"2010-09-09",
"Transform":"AWS::Serverless-2016-10-31",
"Description":"An AWS Serverless Application that uses the ASP.NET Core framework running in Amazon Lambda.",
"Resources":{
"MyFunctionLambda":{
"Type":"AWS::Serverless::Function",
"Properties":{
"Handler":"MyPlatformServerless::MyPlatformServerless.Lambdas.MyFunctionLambda::FunctionHandler",
"Runtime":"dotnetcore2.1",
"CodeUri":"",
"Description":"Default function",
"MemorySize":512,
"Timeout":60,
"Role":null,
"EventInvokeConfig": {
"MaximumRetryAttempts" : 0
}
}
}
}
}您还可以在DestinationConfig对象中指定其他属性,如MaximumEventAgeInSeconds和EventInvokeConfig。
https://stackoverflow.com/questions/61015330
复制相似问题