Aws lambda aws lambda中的Wkhtmltopdf

Aws lambda aws lambda中的Wkhtmltopdf,aws-lambda,wkhtmltopdf,Aws Lambda,Wkhtmltopdf,我正在试穿样品 我被困在考试中。当我运行测试时,会出现如下错误: Execution result: failed(logs) Details The area below shows the result returned by your function execution. Learn more about returning results from your function. { "errorMessage": "RequestId: e518cd5c-2ee0-11e8

我正在试穿样品

我被困在考试中。当我运行测试时,会出现如下错误:

    Execution result: failed(logs)
Details
The area below shows the result returned by your function execution. Learn more about returning results from your function.
{
  "errorMessage": "RequestId: e518cd5c-2ee0-11e8-9af4-abd55dea481f Process exited before completing request"
}
Summary

Code SHA-256
kFqfcOZdsw5hmmn2VZ62QVULXrwqdh3jMDh90EJR4gI=
Request ID
e518cd5c-2ee0-11e8-9af4-abd55dea481f
Duration
1383.09 ms
Billed duration
1400 ms
Resources configured
128 MB
Max memory used
40 MB
Log output
The area below shows the logging calls in your code. These correspond to a single row within the CloudWatch log group corresponding to this Lambda function. Click here to view the CloudWatch log group.
START RequestId: e518cd5c-2ee0-11e8-9af4-abd55dea481f Version: $LATEST
2018-03-23T21:26:49.954Z    e518cd5c-2ee0-11e8-9af4-abd55dea481f    TypeError: Cannot read property 'toString' of null
    at Response.<anonymous> (/var/task/index.js:25:45)
    at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:364:18)
    at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:685:12)
END RequestId: e518cd5c-2ee0-11e8-9af4-abd55dea481f
REPORT RequestId: e518cd5c-2ee0-11e8-9af4-abd55dea481f  Duration: 1383.09 ms    Billed Duration: 1400 ms    Memory Size: 128 MB Max Memory Used: 40 MB  
RequestId: e518cd5c-2ee0-11e8-9af4-abd55dea481f Process exited before completing request

提前感谢您的帮助。

看起来您的pdf变量未定义

我在遵循相同的指南时遇到了这个问题

这是因为在lambda函数项目根中没有包含
wkhtmltopdf
二进制文件

此时,您有两个选择。您可以自己在Amazon Linux AMI EC2实例中构建二进制文件,我听说这很痛苦,或者从其他人那里获取二进制文件。如果它来自非官方来源,我不推荐这样做,但是,您可以找到版本12.4(在撰写本文时,当前版本是12.5)

如果您想自己构建它,AWS Lambda运行在Amazon Linux AMI上,您可以找到当前版本。(更多关于在AWS Lambda中运行可执行文件的信息)

拥有二进制文件后,将其包含在项目根目录中,并确保其可执行,
chmod+x wkhtmltopdf

希望这能帮助其他遇到这种情况的人

其他有用的链接:

发生
AccessDeniedAccess
错误是因为存储桶及其内容不是公共的。要以授权用户身份下载文件,您必须通过aws控制台中的文件属性菜单下载文件,而不是尝试访问链接。

您只需要使用合适版本的wkhtmltopdf.sh文件。lambda支持64位二进制文件(仅64位)。

教程的URL已断开,但我可以在上找到它
AccessDeniedAccess DeniedA6FF69637CAFDA68RjoN8UiT+V5MzrWN0G4h3SeIKgdu6eybNCtQMf+h+x5WxFwI1OyvF0Z2K6fhMP0RRn3RtStEKps=