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
Lambda
Step Function
Simple Notification Service
S3
Websockets
Single report PDF step function - how does it work?
- A
lambda
startsmov-pdfGeneratorStateMachine-{stage}
execution with input asreportId
andpassthrough
* (optional). Apassthrough
is 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
,getReportData
andexecutePDFGenerator
.- Upon successful execution a message will be published to
SNS
and allsubscribers
to theSNS
will receive the image.subscribers
can belambda
,SQS
,email
orhttp/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
false
wait another 10 seconds and repeat. Iftrue
Succeed step function
Run locally, test and deploy
yarn start
will run local serverless configurationyarn test
will run integration testsyarn deploy-{stage}
e.g.yarn deploy-test
serverless 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] -v
Deploy 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] -l
Streaming 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] -t
Cleanup
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 remove
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago