简体   繁体   English

如何获取 CloudFormation 生成的 lambda 的日志组名称和 ARN?

[英]How do I get the log group name and ARN of a lambda generated by CloudFormation?

I'm generating a lambda in CloudFormation like this:我在 CloudFormation 中生成一个 lambda,如下所示:

TestFunction:
  Type: AWS::Serverless::Function
  Properties:
    Handler: lib/test.handler
    Timeout: 30
    Role: !GetAtt ExecutionRole.Arn

Now, CloudFormation will automatically create me a log group for this lambda.现在,CloudFormation 会自动为我创建这个 lambda 的日志组。 How do I access that log groups name and ARN?如何访问该日志组名称和 ARN?

I do NOT want to create a log group and then associate it to my lambda.我不想创建一个日志组,然后将其关联到我的 lambda。 I want to access the log group that is created for me automatically.我想访问自动为我创建的日志组。

Log group created by a lambda function will have a name of the form /aws/lambda/<function name> .由 lambda function 创建的日志组将具有/aws/lambda/<function name>形式的名称。 See here: https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-logs.html请参阅此处: https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-logs.html

You can construct the name of the log group with:您可以使用以下命令构造日志组的名称:

!Sub '/aws/lambda/${TestFunction}'

and the arn:和 arn:

!Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${TestFunction}:*'

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

相关问题 在 Cloudformation 模板中,如何在 IoT 规则中引用动态生成的 Lambda function ARN? - In a Cloudformation template, how do I reference a dynamically generated Lambda function ARN in an IoT Rule? 如何获取 AWS 中安全组的 ARN - How do I get the ARN for a security group in AWS 如何在 CloudFormation 中获取 SSM 文档的 ARN? - How to get the ARN of an SSM Document in CloudFormation? 如何获取 Cloud Formation 特定资源属性的 AWS Lambda 函数的 ARN? - How do I get the ARN of an AWS Lambda function for a Cloud Formation specific resource property? 如何使用 cloudformation 从 S3 ARN 获取 S3 存储桶名称 - How to get S3 bucket name from S3 ARN using cloudformation 如何获取通过 Terraform 生成的资源(IAM 角色)的 AWS ARN 以在 Lambda ZC1C425268E17A98 的 Java 代码中使用 - How to get AWS ARN of resource (IAM role) generated through Terraform to use in Java code of Lambda function? 如何在 CDK 中获取 lambda function 的 ARN - How to get the ARN of a lambda function in CDK 从 cloudformation 堆栈中检索 lambda 函数的 arn - Retrieve the arn of a lambda function from a cloudformation stack 使用 cloudformation 部署时如何获取 AWS Api 网关的 arn - How to get arn of AWS Api gateway when deploying with cloudformation AWS CloudFormation:如何获取 DynamoDB GlobalTable 副本的 stream ARN? - AWS CloudFormation: How to get stream ARN of DynamoDB GlobalTable replica?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM