amazon-web-services - 如何在cloudformation lambda 中设置aws lambda 的maximumRetryAttempt?

标签 amazon-web-services aws-cloudformation

我有一个通过 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 内在函数。对于 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"
            }
        }
    }
}

关于amazon-web-services - 如何在cloudformation lambda 中设置aws lambda 的maximumRetryAttempt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61015330/

相关文章:

amazon-web-services - 为什么在 AWS CLI 中使用预签名 URL 时需要指定区域?

amazon-web-services - AWS Elasticsearch EC2 Discovery,无法找到其他节点

amazon-web-services - Cloudformation 输出 : Template format error: Every Value member must be a string

amazon-web-services - 引用 AppSync 和 Cognito Auth 的现有设置

amazon-web-services - 云信息和参数存储 : How to select parameter for the environment

amazon-web-services - Binderhub 是否有 AWS 支持?

aws-cloudformation - cloudformation包上传hash而不是zip

amazon-web-services - 使用 SDK 检查 Cognito 域前缀可用性

amazon-web-services - AWS SAM : can we use a already existing api in aws sam template?

amazon-web-services - 如何获取 AWS 中安全组的 ARN