My template for making a basic lambda function when there's no API call -- such as when the function is triggered by CloudWatch (such as every 15 mins) or by an Alexa command.
For lambda functions triggered by API calls, I use
claudia-api-builder. My Party Bot is a simple exapmle of that.
I add these to my repo:
.gitignoreis my file for ignoring files.
index.jsis where I build the bot. This will get called by the lambda function.
test.jsis how I run
index.jslocally, to test it:
Setting Up Claudia
npm init --yes npm install claudia --save-dev
Here are some important notes about the creation command I'm about to run:
- I use the full path to claudia because it sometimes doesn't work otherwise
- In this app, the bot runs in
- The "index.handler" in the command below comes from the name of the file
index.jsand the module inside that file
- For permission to run/use the function, I'm using a "role" I've already set up instead of my own credentials. The role was set up in IAM, Amazon's permissions system. More about that in the Claudia installation documents.
- Other arguments for the
createcommand are listed here.
So this command creates the lambda function initially:
./node_modules/.bin/claudia create --region us-east-1 --handler index.handler --role lambda_basic_execution
Any subsequent updates can skip all of that and just use this command: