[英]How can i set the maximumRetryAttempt for aws lambda in the cloudformation lambda?
I have a serverless project created throught visual studio and i'm looking for setting the maximumRetryAttempt of a specific lambda in the cloudformation template.我有一个通过 Visual Studio 创建的无服务器项目,我正在寻找在 cloudformation 模板中设置特定 lambda 的最大重试次数。 I saw EventInvokeConfig, however the lambda function name is generated automatically and different from each environment.
我看到了 EventInvokeConfig,但是 lambda function 名称是自动生成的,并且每个环境都不同。 I am wondering if there is an aws specific parameter to get a lambda function name?
我想知道是否有特定于 aws 的参数来获取 lambda function 名称?
"EventInvokeConfig": {
"Type" : "AWS::Lambda::EventInvokeConfig",
"Properties" : {
"FunctionName" : "???",
"MaximumRetryAttempts" : 0,
"Qualifier" : "$LATEST"
}
}
Here is my serverless template这是我的无服务器模板
{
"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
}
}
}
}
You can make use of the Ref
instrinsic function.您可以使用
Ref
内在 function。 For the resource of type AWS::Serverless::Function
the returned value is the name of the function.对于
AWS::Serverless::Function
类型的资源,返回值为 function 的名称。
This can be referenced in other resources defined in the template.这可以在模板中定义的其他资源中引用。 For
EventInvokeConfig
, the template would look like对于
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"
}
}
}
}
Your issue might have resolved already but you can improve the code.您的问题可能已经解决,但您可以改进代码。 As you're using Serverless (SAM) you can directly specify the
EventInvokeConfig
in the lambda resource properties and no need of another resource creation.当您使用无服务器 (SAM) 时,您可以直接在 lambda 资源属性中指定
EventInvokeConfig
,而无需创建其他资源。 Please find the below snippet:请找到以下代码段:
{
"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
}
}
}
}
}
You can also specify other attributes like DestinationConfig
and MaximumEventAgeInSeconds
in the EventInvokeConfig
object.您还可以在
EventInvokeConfig
object 中指定其他属性,例如DestinationConfig
和MaximumEventAgeInSeconds
。
References: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-eventinvokeconfiguration.html
参考: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-eventinvokeconfiguration.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.