AWS Lambda @ Edge调试 [英] AWS Lambda@Edge debugging

查看:285
本文介绍了AWS Lambda @ Edge调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用lambda @ edge函数。
我无法在CloudWatch或其他调试选项上找到任何日志。



使用测试按钮运行lambda时,日志将写入CloudWatch。 / p>

当CloudFront事件触发lambda函数时,不会写入日志。



我是100%



任何想法如何进行都是可以肯定的。



谢谢,

Yossi

解决方案

1)确保您已授予lambda将日志发送到cloudwatch的权限。下面是 AWSLambdaBasicExecutionRole 策略,您需要将该策略附加到用于lambda函数的执行角色。

  {
版本: 2012-10-17,
声明:[
{
效果:允许,
动作:[
logs:CreateLogGroup,
logs:CreateLogStream,
logs:PutLogEvents
],
资源: *
}
]
}

2)Lambda创建最靠近执行功能的位置的CloudWatch Logs区域中的CloudWatch Logs日志流。每个日志流的名称格式为 /aws/lambda/us-east-1.function-name ,其中 function-name 是您为函数创建时。因此,请确保您正在正确的 REGION 中检查cloudwatch日志。


I'm currently working on a lambda@edge function. I cannot find any logs on CloudWatch or other debugging options.

When running the lambda using the "Test" button, the logs are written to CloudWatch.

When the lambda function is triggered by a CloudFront event the logs are not written.

I'm 100% positive that the event trigger works, as I can see its result.

Any idea how to proceed?

Thanks ahead,
Yossi

解决方案

1) Ensure you have provided permission for lambda to send logs to cloudwatch. Below is the AWSLambdaBasicExecutionRole policy which you need to attach to the exection role which you are using for your lambda function.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }
    ]
}

2) Lambda creates CloudWatch Logs log streams in the CloudWatch Logs regions closest to the locations where the function is executed. The format of the name for each log stream is /aws/lambda/us-east-1.function-name where function-name is the name that you gave to the function when you created it. So ensure you are checking the cloudwatch logs in the correct REGION.

这篇关于AWS Lambda @ Edge调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆