Sample node app for processing SQS messages, that you can run locally using AWS SAM.
You can use this as a starter repository for new projects to get started quickly :)
Things you need installed:
- Node 12.x and npm --> https://nodejs.org/en/download/
- AWS Sam --> https://aws.amazon.com/serverless/sam/
Is this your first time? Then you need to install the node modules, see below
npm install
npm run package && sam build && sam local invoke SQSFunction --event events/event-sqs.json
Login with with BSS cli to dev account
npm run package && sam build && sam local invoke DynamoFunction
Login with with BSS cli to dev account
npm run package && sam build && sam local invoke SecretsFunction
After you ran npm install
npm run package
sam build
sam local invoke SQSFunction --event events/event-sqs.json
OR the shorthand way:
npm run package && sam build && sam local invoke SQSFunction --event events/event-sqs.json
So what do the above commands do for you?
npm run package
: Converts the typescript for you into javascript so that Lambda can run itsam build
: Tells AWS SAM to read the template.yaml file which packages up the node app in a friendly way for the SAM app to call it like a lambda functionsam local invoke SQSFunction --event events/event-sqs.json
: Tells SAM to run the app locally and trigger the handler with that event, in this case it's an SQS event
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings. With just a few lines per resource, you can define the application you want and model it using YAML. During deployment, SAM transforms and expands the SAM syntax into AWS CloudFormation syntax, enabling you to build serverless applications faster.