amazon-web-services - 如何在 cloudformation lambda 中为 aws lambda 设置 maximumRetryAttempt?
问题描述
我有一个通过 Visual Studio 创建的无服务器项目,我正在寻找在 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
}
}
}
}
解决方案
您可以利用Ref
内在功能。对于 type 的资源,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"
}
}
}
}
推荐阅读
- python-3.x - 每次运行 Python / Selenium 脚本时,它的行为都会有所不同
- r - R:如何在某个关键短语之前和之后提取子字符串?
- sql - SQL中的后/前填充值
- reactjs - React 使用 Hooks 处理链接的条件渲染
- python - python - 如何使用 glob.glob 创建包含大量数据帧的字典
- docker - 在 docker exec -it 之后持久化 gradle 守护进程
梯度构建 - unity3d - Unity Rigidbody2d.addforce 在施加力后不会改变方向
- google-cloud-platform - 如何在合作防火墙后面的谷歌云平台上进行 git clone?
- javascript - 如何读取具有不同名称的所有 json 数据
- c# - 我的 .Net 标准库的传递依赖项没有复制到正在执行的程序集中在哪里?