Skip to content

DavidWells/serverless-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Workshop

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.

Table of Contents

Using this repo

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:

  • /lessons - ✅ work from these files!
  • /lessons-code-complete - 💡Complete lesson answers
  • /_instructor - 🙈 ignore these, unless updating lessons

Workshop Lessons

Core Concepts

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

Events

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

Helpful Tools

Prerequisites & Setup Steps

  1. Install the latest LTS version of Node. How to install Node.

  2. 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.

  3. 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.

  4. Install serverless CLI

    Open up your terminal and run:

    npm install serverless -g
  5. Connect the serverless CLI with your AWS account credentials

    See the docs or watch the video

  6. 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:

  • If you have an IDE/editor with YAML linting it will be helpful. (like this atom plugin, or vs code plugin)
  • Install postman for quick & easy testing of endpoints we deploy
  • It's also recommended that you use nvm (node version manager) just in case you need to change versions of node for the workshop.

Troubleshooting & FAQ

  • 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

About

⚡️ Open source serverless workshop. Ready to deploy serverless examples on AWS

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published