Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/barchart/aws-lambda-pdf-generator/llms.txt

Use this file to discover all available pages before exploring further.

The AWS Lambda PDF Generator is deployed as a fully serverless stack using the Serverless framework. Running yarn deploy:prod from the project root orchestrates the entire process: it first builds a packaged Chromium Lambda Layer locally via make, then provisions all AWS resources — API Gateway, Lambda functions, IAM roles, CloudWatch log groups, and the Chromium layer — in a single CloudFormation changeset. No manual console steps are required.

Prerequisites

Before deploying, ensure the following tools are installed and configured:

What Gets Deployed

A single yarn deploy:prod command deploys the serverless-pdf-generator service and creates the following AWS resources in your account:
ResourceDetails
API GatewayHTTP REST endpoint that routes incoming requests to Lambda
Lambda function — printConverts HTML to PDF using Puppeteer and Chromium; 2048 MB memory, 30-second timeout
Lambda function — serviceReadReturns service metadata (version); lightweight, no Chromium layer
Lambda Layer — HeadlessChromiumContains Chromium v122 compatible with nodejs20.x; built locally before deploy
IAM RoleGrants the Lambda functions s3:GetObject and s3:PutObject access to the large-response S3 bucket
CloudWatch Log GroupsOne per Lambda function; logs are retained for 90 days

Deployment Steps

1

Clone the repository

Clone the project and navigate into the root directory:
git clone https://github.com/barchart/aws-lambda-pdf-generator.git
cd aws-lambda-pdf-generator
2

Install dependencies

Install all workspace dependencies from the monorepo root. Yarn workspaces will link the packages/api package automatically:
yarn install
3

Deploy to AWS

Run the appropriate deploy script for your target stage.Production:
yarn deploy:prod
Staging:
yarn deploy:stage
Before the Serverless CLI is invoked, the predeploy script automatically runs make clean && make all inside packages/api. This clones the @sparticuz/chromium repository at the v122.0.0 tag, compiles it, and produces the layer artifact at packages/api/layers/chromium-v122.zip. The Serverless framework then uploads this artifact as the HeadlessChromium Lambda Layer.

Stages

The project supports two named deployment stages. Each stage is an independent CloudFormation stack and creates separate AWS resources:
StageDeploy commandUse case
stageyarn deploy:stageIntegration testing, QA validation
prodyarn deploy:prodLive production traffic
The active stage name is injected into each Lambda function as the NODE_ENV environment variable, allowing the application code to branch on environment at runtime.
Your AWS IAM user or role must have sufficient permissions to deploy this stack. At a minimum, the following service permissions are required: Lambda, API Gateway, IAM (role and policy management), S3 (deployment bucket access), CloudFormation, and CloudWatch Logs.
If you are re-deploying after a previous installation — especially if the stack name or stage has changed — remove the old stack first to avoid CloudFormation naming conflicts:
cd packages/api
sls remove --stage prod
Then re-run the deploy from the project root.

Build docs developers (and LLMs) love