简体   繁体   English

最新的 Lambda 层 ARN

[英]Latest Lambda Layer ARN

I have a lambda layer which I keep updating.我有一个不断更新的 lambda 层。 This lambda layer has multiple versions.这个 lambda 层有多个版本。 How can I find the lambda layer ARN with latest version using aws cli?如何使用 aws cli 找到最新版本的 lambda 层 ARN?

I am able to do this using the command listed below -我可以使用下面列出的命令来做到这一点 -

aws lambda list-layer-versions --layer-name <layer name> --region us-east-1 --query 'LayerVersions[0].LayerVersionArn'

Unfortunately, it's currently not possible (I have encountered the same issue).不幸的是,目前不可能(我遇到了同样的问题)。

You can keep the latest ARN in your own place (like DynamoDB) and update it whenever you publish a new version of the layer.您可以将最新的 ARN 保存在您自己的位置(如 DynamoDB),并在您发布层的新版本时更新它。

You can create a custom macro to get the latest lambda layer version and use that as a reference.您可以创建自定义宏以获取最新的 lambda 层版本并将其用作参考。

The following function gets the latest version from the Lambda Layer stack:以下函数从 Lambda 层堆栈获取最新版本:

import json
import boto3


def latest_lambdalayer(event, context):
    
    fragment = get_latestversion(event['fragment'])
    return {
      'requestId': event['requestId'],
      'status': 'success',
      'fragment': fragment
    }

def get_latestversion(fragment):
    cloudformation = boto3.resource('cloudformation')
    stack = cloudformation.Stack('ticketapp-layer-dependencies')
    for o in stack.outputs: 
        if o['OutputKey']=='TicketAppLambdaDependency':
            return o['OutputValue']
    #return "arn:aws:lambda:eu-central-1:899885580749:layer:ticketapp-dependencies-layer:16"

And you use this when defining the Lambda layer—here using same global template:在定义 Lambda 层时使用它——这里使用相同的全局模板:

Globals:
  Function:
    Layers:
      - !Transform { "Name" : "LatestLambdaLayer"}
    Runtime: nodejs12.x
    MemorySize: 128
    Timeout: 101

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导出 Lambda ARN - Export the Lambda ARN 如何将 package AWS CDK 转化为 Lambda 层? - How to package AWS CDK into Lambda layer? 如何访问上传到python aws lambda中的层的yaml文件 - How to access a yaml file uploaded to a layer in a python aws lambda 从 lambda 层加载时无服务器离线未定义模块 - Serverless Offline undefined module when loaded from lambda layer 如何在 nodeJS 中获取 AWS SQS 队列 ARN? - How to get AWS SQS queue ARN in nodeJS? 如何在 cloudformation 策略文档中引用资源 ARN? (山药) - How to reference a resource ARN in a cloudformation policy document ? (yaml) 通过策略禁用单个 ARN 的 S3 请求者付款设置 - S3 Requester Pays setting disabled for single ARN via the policy AWS::WAFv2::LoggingConfiguration 在使用 Cloudformation 创建堆栈时遇到无效的 ARN - AWS::WAFv2::LoggingConfiguration encounter invalid ARN when creating stack with Cloudformation Amazon Lex 错误:调用 PutIntent 操作时发生错误 (BadRequestException):RelativeId 与 Lex ARN 格式不匹配 - Amazon Lex Error: An error occurred (BadRequestException) when calling the PutIntent operation: RelativeId does not match Lex ARN format AWS Lambda - 调用另一个 lambda 函数的方法 - AWS Lambda - Invoke a method of another lambda function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM