EventType:lambda edge 的查看器请求结果为 503
EventType: viewer-request results in 503 for lambda edge
我在文档中找不到任何解释此问题的内容。我几乎一字不差地关注了这个博客 post:https://aws.amazon.com/blogs/networking-and-content-delivery/managing-lambdaedge-and-cloudfront-deployments-by-using-a-ci-cd-pipeline/
它按预期工作,但我想为查看器请求添加另一个事件,这样我就可以立即测试我的功能,而无需等待对象过期。
我将此添加到模板中:
LambdaFunctionAssociations:
-
EventType: origin-request
LambdaFunctionARN: !Ref LambdaEdgeFunctionSample.Version
# Adding this to hit my function on every user request
-
EventType: viewer-request
LambdaFunctionARN: !Ref LambdaEdgeFunctionSample.Version
这会导致以下错误:
The Lambda function associated with the CloudFront distribution is
invalid or doesn't have the required permissions. We can't connect to
the server for this app or website at this time. There might be too
much traffic or a configuration error. Try again later, or contact the
app or website owner. If you provide content to customers through
CloudFront, you can find steps to troubleshoot and help prevent this
error by reviewing the CloudFront documentation.
我不确定为什么会这样,甚至不知道如何解决它。我知道该函数有效,因为 origin-request 成功执行了该函数。
检查您的 CloudWatch 日志组(找到离您发出请求的位置最近的区域,否则您可能需要四处寻找)。
一个常见的原因可能是您的查看器请求未产生正确的响应。
Lambda@Edge 不会向客户端透露太多错误,从安全角度来看这很好,但这意味着您需要深入了解 CloudWatch 以查看发生了什么错误。
您可能还会遇到诸如超过 5 秒持续时间或 128MB 内存限制之类的问题,我不记得他们是否抛出 503 以外的任何内容。
我在文档中找不到任何解释此问题的内容。我几乎一字不差地关注了这个博客 post:https://aws.amazon.com/blogs/networking-and-content-delivery/managing-lambdaedge-and-cloudfront-deployments-by-using-a-ci-cd-pipeline/
它按预期工作,但我想为查看器请求添加另一个事件,这样我就可以立即测试我的功能,而无需等待对象过期。
我将此添加到模板中:
LambdaFunctionAssociations:
-
EventType: origin-request
LambdaFunctionARN: !Ref LambdaEdgeFunctionSample.Version
# Adding this to hit my function on every user request
-
EventType: viewer-request
LambdaFunctionARN: !Ref LambdaEdgeFunctionSample.Version
这会导致以下错误:
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner. If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
我不确定为什么会这样,甚至不知道如何解决它。我知道该函数有效,因为 origin-request 成功执行了该函数。
检查您的 CloudWatch 日志组(找到离您发出请求的位置最近的区域,否则您可能需要四处寻找)。
一个常见的原因可能是您的查看器请求未产生正确的响应。
Lambda@Edge 不会向客户端透露太多错误,从安全角度来看这很好,但这意味着您需要深入了解 CloudWatch 以查看发生了什么错误。
您可能还会遇到诸如超过 5 秒持续时间或 128MB 内存限制之类的问题,我不记得他们是否抛出 503 以外的任何内容。