mov-pdf-generator v1.3.3
PDF Generator
Overview
The application generates a report pdf using puppeteer and save PDF in an S3 Bucket.
Scope and Limitation
Receives an external trigger such as lambda or API Gateway to generate report pdf. Can generate multiple PDFs at once.
Out of scope
To be updated
Dependencies
Applications / Serverless Application Dependent to mov-pdf-generator
AWS Services
LambdaStep FunctionSimple Notification ServiceS3Websockets
Single report PDF step function - how does it work?

- A
lambdastartsmov-pdfGeneratorStateMachine-{stage}execution with input asreportIdandpassthrough* (optional). Apassthroughis any data passed from the requester to the end of the step function and possibly can be use by another service. mov-pdfGeneratorStateMachine-{stage}is composed ofgetReport,getReportDataandexecutePDFGenerator.- Upon successful execution a message will be published to
SNSand allsubscribersto theSNSwill receive the image.subscriberscan belambda,SQS,emailorhttp/s - Upon invalid execution the error information will be send to recipients defined in AWS SNS console
Public interface
PDF Generator can be invoked using websockets.
- Connect to websocket service
wss://c2sa43bpif.execute-api.us-east-1.amazonaws.com/STAGE?token=YOUR_METJWT_TOKEN - Service consumes generateReportPdf action only together with reportId payload. Example:
{"action": "generateReportPdf", "reportId": "YOUR_REPORT_ID"} - Once the report is generated, service emits generateReportSucceeded.
- Your application should handle all possible actions.
Multiple report PDFs - how does it work

Step function above executes multiple step functions for each reportId. Then it waits for all of them to be finished
- To start execution of multiple PDFs you have specify array of report ids. Such as:
{ "reportIds": ["3f0aebef-30e7-405e-bce1-ba116242a9be", "8a829a00-fdcc-4d81-b37e-887402b81493"], "passThroughProps": {} } - Wait 10 seconds
- Check if all step functions executed by this wrapper are finished (succeeded)
- If
falsewait another 10 seconds and repeat. IftrueSucceed step function
Run locally, test and deploy
yarn startwill run local serverless configurationyarn testwill run integration testsyarn deploy-{stage}e.g.yarn deploy-testserverless deploy -s {stage} function -f {lambdaFunctionName}to deploy a function
Workflow - from official serverless site
Read this on the main serverless docs site
Cheat Sheet
A handy list of commands to use when developing with the Serverless Framework.
Deploy All
Use this when you have made changes to your Functions, Events or Resources in serverless.yml or you simply want to deploy all changes within your Service at the same time.
serverless deploy -s [STAGE NAME] -r [REGION NAME] -vDeploy Function
Use this to quickly overwrite your AWS Lambda code on AWS, allowing you to develop faster.
serverless deploy function -f [FUNCTION NAME] -s [STAGE NAME] -r [REGION NAME]Invoke Function
Invokes an AWS Lambda Function on AWS and returns logs.
serverless invoke -f [FUNCTION NAME] -s [STAGE NAME] -r [REGION NAME] -lStreaming Logs
Open up a separate tab in your console and stream all logs for a specific Function using this command.
serverless logs -f [FUNCTION NAME] -s [STAGE NAME] -r [REGION NAME] -tCleanup
If at any point, you no longer need your service, you can run the following command to remove the Functions, Events and Resources that were created, and ensure that you don't incur any unexpected charges.
serverless remove4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago