【发布时间】:2019-01-07 23:32:38
【问题描述】:
在this article 之后,我正在尝试在 AWS 中提供来自多个区域(同一域下)的静态内容。
到目前为止,我有:
- 已将我的内容上传到 S3 存储桶中
- 为该存储桶启用“静态网络托管”
- 并公开
- 在 CloudFront 中创建了一个以 S3 存储桶为源的分配
- 在 Route 53 中创建了一个指向分布的记录集
此时,一切正常。如果我在浏览器中输入域名,我可以看到静态内容。现在是时候让它多区域了:
- 按照文章中的说明创建一个具有 AdministratorAccess 策略的角色的 lambda 函数(出于绝望 - 一旦我让它工作,我会仔细设计合适的角色)
- 将 lambda 函数链接到 CloudFront:
Event type: origin-request, Include body: No, Path pattern: * - 编辑了 CloudFront 分配,添加了标题
X-DNS-ORIGIN
应用这些步骤后,我必须等待一分钟才能生效。一旦它们生效,我就无法再打开网页了。这样做会导致此错误消息:
503 ERROR
The request could not be satisfied.
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions.
If you received this error while trying to use an app or access a website, please contact the provider or website owner for assistance.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by following steps in the CloudFront documentation (http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-503-service-unavailable.html).
Generated by cloudfront (CloudFront)
我什至启用了 CloudFront 的日志记录机制。但这也无济于事。日志只显示有一个LambdaExecutionError。但它并没有说任何有用的东西。
我认为根本没有调用 lambda 函数,因为我在 CloudWatch 中没有看到为它生成的任何日志。在这一点上,我不知道如何解决这个问题。任何帮助表示赞赏。
[编辑]
我忘了提。分配给 lambda 函数的角色在其信任关系选项卡中将 lambda.amazonaws.com 和 edgelambda.amazonaws.com 列为服务。
【问题讨论】:
-
@Michael-sqlbot 除非我做错了,否则已经完成了。我忘了在帖子里提到它。谢谢。
标签: amazon-web-services amazon-cloudfront aws-lambda-edge