【问题标题】:Tachyon image processing - CloudFront configuration - The specified key does not exist - NoSuchKeyTachyon 图像处理 - CloudFront 配置 - 指定的密钥不存在 - NoSuchKey
【发布时间】:2019-12-22 20:56:31
【问题描述】:

有没有人在使用最新的 CloudFormation 模板和最新的发布包时遇到过上述问题? (lambda.zip)

套装包括:

index.js lambda-handler.js 节点模块 代理文件.js server.js

CloudFormation 配置:

API 网关 Lambda 函数 CloudFront 分布

https://github.com/humanmade/tachyon

对我来说,这表明该对象不存在。但是,它确实存在,并且大量测试可以确认该对象存在并且公开可用。如果我直接调用 api 网关并传递参数,则 lambda 不会引发任何错误,但是,通过 CloudFront - 它几乎就像它转换请求的 url 并中断请求?

https://my.custom.domain.co.uk/image.jpeg?resize=100,100 - 这通过 CloudFront 分配,但 Lambda 错误表明不存在这样的密钥。该图像绝对可以通过域名和图像路径访问,因为它在浏览器中加载时不会出现问题。但是,传递调整大小的参数似乎会破坏函数。

{
"errorMessage": "The specified key does not exist.",
"errorType": "NoSuchKey",
"stackTrace": [
"Request.extractError (/var/runtime/node_modules/aws-sdk/lib/services/s3.js:585:35)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
"Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
"AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
"/var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
]
}
  • 使用提供的 CloudFormation 模板
  • 使用提供的 Tachyon 代码
  • Tachyon 代码的一个存储桶
  • 一个图片存储桶 - 可公开访问
  • 根据指南为存储桶名称和区域提供 Lambda 变量
  • DNS Cname 将域指向 CloudFront 分配

对我来说,这似乎是 CloudFront 配置的问题

"errorMessage": "The specified key does not exist.",
"errorType": "NoSuchKey",
"stackTrace": [
"Request.extractError (/var/runtime/node_modules/aws-sdk/lib/services/s3.js:585:35)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
"Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
"AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
"/var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
]
}

预期结果是 - https://my.custom.domain.co.uk/image.jpeg?resize=100,100 将调整大小的图像返回给浏览器。

实际结果 - aws-sdk 中没有此类密钥的 Lambda 错误

任何指导将不胜感激。

谢谢

【问题讨论】:

  • 您是如何格式化对 S3 存储桶的引用的?
  • 因此使用 Lambda 上的环境变量(根据 Tachyon 文档)S3_BUCKET(存储桶名称)和 S3_REGION(us-east-1)来引用存储桶 - 然后我在我在 url 中引用的存储桶的根。
  • “如果我直接调用 api 网关并传递参数,则 lambda 不会抛出任何错误”如果它已经通过使用 API Gateway 端点来工作,那么为什么不将它用于您的项目呢?我对 Tachyon 不熟悉,但我知道 CloudFront 已经在默认情况下与 API 网关端点一起使用:docs.aws.amazon.com/apigateway/latest/developerguide/…

标签: amazon-cloudformation amazon-cloudfront aws-sdk-nodejs sharp tachyon


【解决方案1】:

cfn-lint 输出:

E0000 Duplicate resource found "Handler" (line 162)
cloudformation-template.json:162:9

根据AWS::Lambda::Function docs,这种资源类型应该有一个Handler 属性。您的意思是为此资源指定多个Handler 属性吗?

【讨论】:

  • 感谢您强调这一点 - CloudFormation 模板来自 Tachyon 存储库 - 但是,Lambda 控制台中唯一可见的处理程序是 lambda-handler - 但我猜这引用了 index.js 文件?看起来它处理 Tachyon 操作..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-12
相关资源
最近更新 更多