wkhtmltopdf-lambda
is a simple wrapper which runs wkhtmltopdf
as an AWS Lambda function.
rustup target add x86_64-unknown-linux-musl
- Configure aws-cli credentials
- Create an S3 bucket, e.g.
s3://wkhtmltopdf
- Create a role with CloudWatch and S3 permissions, e.g.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "logs:CreateLogGroup", "Resource": "arn:aws:logs:us-east-1:000000000000:*" }, { "Effect": "Allow", "Action": [ "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": [ "arn:aws:logs:us-east-1:000000000000:log-group:/aws/lambda/wkhtmltopdf-rust:*" ] }, { "Effect": "Allow", "Action": [ "s3:GetObject" ], "Resource": "arn:aws:s3:::wkhtmltopdf/*" }, { "Effect": "Allow", "Action": [ "s3:PutObject" ], "Resource": "arn:aws:s3:::wkhtmltopdf/*" } ] }
just create-layer
env LAMBDA_ROLE="arn:aws:iam::000000000000:role/wkhtmltopdf" just create-function
(or use.env
file)
Alternatively, instead of creating a layer, just create-function true
can be used to bundle both the wrapper and wkhtmltopdf
itself together.
just test-function
just pack
(wrapper only) or just pack true
(bundled wkhtmltopdf
)
See:
https://github.com/softprops/serverless-rust