Skip to content

BGLCorp/wkhtmltopdf-lambda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What

wkhtmltopdf-lambda is a simple wrapper which runs wkhtmltopdf as an AWS Lambda function.

How

Dependencies

  1. rust, rustup
  2. (Suggested) musl libc
  3. (Optional) just, aws-cli, jq and a few other common CLI tools

Build & Deploy

  1. rustup target add x86_64-unknown-linux-musl
  2. Configure aws-cli credentials
  3. Create an S3 bucket, e.g. s3://wkhtmltopdf
  4. 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/*"
            }
        ]
    }
  5. just create-layer
  6. 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.

Test

just test-function

Packaging

just pack (wrapper only) or just pack true (bundled wkhtmltopdf)

See:

https://github.com/softprops/serverless-rust

https://github.com/vvilhonen/cargo-aws-lambda

Targeting Glibc

See: https://github.com/softprops/lambda-rust

About

Simple wkhtmltopdf wrapper in AWS Lambda

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%