This repo will teach you the core concepts of serverless and walk through a variety of ready to deploy serverless architectures
If you'd like the serverless training for your team, get in touch with me.
After following the prerequisite setup steps, work from the lessons folders.
If you get stuck or want to look ahead checkout the lessons-code-complete directory for the completed code.
Repo directory structure:
Lesson | Final Code |
---|---|
1 Http Hello World Deploying Your First Endpoint |
Complete Code |
2 Http Dynamic Content Dynamic Content in Functions |
Complete Code |
3 Http Post With Cors Deploying an http POST endpoint with CORS support |
Complete Code |
4 Using Env Vars Using environment variables |
Complete Code |
5 Using Serverless Variable Syntax Using Serverless variable syntax |
Complete Code |
6 Using Addition Resources Defining additional resources |
Complete Code |
7 Using Serverless Plugins Extending Serverless Functionality with plugins |
Complete Code |
8 Using Multiple Stages Deploying to Multiple Stages |
Complete Code |
Lesson | Final Code |
---|---|
Dynamodb Streams Using DynamoDB streams |
Complete Code |
Kinesis Basic Simple Kinesis Example |
Complete Code |
Kinesis Using Kinesis as an Event Source |
Complete Code |
S3 Triggering Lambda functions from s3 events |
Complete Code |
Schedule Triggering functions via cron schedules |
Complete Code |
Sns Using AWS SNS as event source |
Complete Code |
Sns Advanced Using External SNS Topics Example |
Complete Code |
Sns Basic Basic SNS Example |
Complete Code |
Step Functions Using AWS Step Functions |
Complete Code |
Install the latest LTS version of Node. How to install Node.
Verify you have git on your machine
Most machines come pre-loaded with git. 🎉
To verify you have git
, open up your terminal and run:
which git
This should return a path of where git is installed. If the command returns git not found
, we will need to install git on your machine.
Setup a AWS account.
If you don't already have an AWS account, let's get one setup.
Click here to setup a free AWS account
It's recommended to not use pre-existing AWS account running production code.
Make sure you add valid billing information and verify your account.
Open up your terminal and run:
npm install serverless -g
Connect the serverless CLI with your AWS account credentials.
Verify the Serverless CLI works on your machine
Open up your terminal and run:
serverless --help
This should return the list of commands from the CLI tool.
Now let's verify your AWS account is correctly configured. Open up your terminal and run the following commands:
# create a test project
serverless create --template aws-nodejs --path my-test-service
# move into the `my-test-service` directory
cd my-test-service
# deploy the test service to verify AWS credentials
serverless deploy
This should deploy the test service into AWS. If you encounter errors, please ping me and we can get them sorted out.
Bonus setup:
I don't see my [insert AWS service XYZ] in the AWS console
This happens to the best of us. Make sure you are in the correct region in the AWS console. You can get the current region of your service by typing sls info
into the terminal.
serverless deploy
hangs
This typically happens when aws credentials are misconfigured. Double check your ~/.aws/credentials
file and make sure the values are correct.
Y A M L Exception
check your yaml
indentation syntax. yaml validator | yaml validator two
Unable to import module 'handler': Error at Function.Module._resolveFilename (module.js:469:15)
This error means lambda can't find your included node_modules
. Make sure you npm install
in your project and install all your dependancies locally before running sls deploy
Unable to delete bucket
error.
Your s3 bucket in question might have files in it. You will need to head into AWS cloudformation in the console and manually delete the bucket and cloudformation stack.
Stack [xyz] cannot be deleted while in status UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS
This happens when cloudformation gets stuck in a weird state. You might need to log into the AWS console, head into cloudformation and delete the stack from the UI