The project named Serverless that helps you build “serverless” apps (with a name that makes it difficult to Google anything).

Concepts/Things to Know

  • Serverless Framework (Traditional) - This is the client-side tool which turns your YAML into

  • Serverless Components - This is where your code is pushed up to serverless.com to the “Components Engine”, where it does some magic and pushes it to the cloud provider. Note that this means that serverless.com will receive your AWS credentials.

    • All the Serverless Components are on GitHub
    • Components abstract away much of the provider-specific info. Instead that sort of stuff is calculated server-side (by serverless.com), so you have much less local configuration.
    • Components are also required for serverless dev real-time dev mode.

Serverless Components

Getting started

Install npm i -g serverless first. Then:

  1. Create an app in the Serverless web console, from one of the starter templates, or from an existing local Serverless Framework project.

  2. Use the command serverless init xxxxxx where xxxxxx is an ID of a new app which has been generated by the web console.

  3. serverless deploy to deploy to public cloud.

The client will create a CloudFormation stack and apply it, upload the necessary resources to the cloud provider.

Or, in an existing project

cd my-project/

# To create a Lambda
sls init aws-lambda-starter -d my-api

# To create a DynamoDB
sls init aws-dynamodb-starter -d my-database

Working with components.

Use serverless registry to see the list of serverless components available:

$ serverless registry

serverless ⚡registry

Run "serverless init <package>" to install a template...

• fullstack-app - https://github.com/serverless-components/fullstack-app
• express-starter - https://github.com/serverless-components/express/tree/master/templates/express-starter
• react-starter - https://github.com/serverless-components/website/tree/master/templates/react-starter
• graphql-starter - https://github.com/serverless-components/graphql/tree/master/templates/graphql-starter
• aws-lambda-starter - https://github.com/serverless-components/aws-lambda/tree/master/templates/aws-lambda-starter
• aws-dynamodb-starter - https://github.com/serverless-components/aws-dynamodb/tree/master/templates/aws-dynamodb-starter
• aws-iam-role-starter - https://github.com/serverless-components/aws-iam-role/tree/master/templates/aws-iam-role-starter
• aws-lambda-layer-starter - https://github.com/serverless-components/aws-lambda-layer/tree/master/templates/aws-lambda-layer-starter

Find more here: https://github.com/serverless-components

Troubleshooting

“service” property is missing in serverless.yml

  • This seems to happen when you use the newer “Serverless Components” approach, instead of the old method of defining a service name in your serverless.yml file.
  • Not really sure why this happens.
  • I can’t do serverless dashboard in the root directory of a Serverless Components project either.

On a React front-end site, sls deploy fails with “Command failed: npm run build…“:

  • No cause for the error is shown, or the error is swallowed up by npm/sls. So the real reason for the failed build can be hidden, for some reason.
  • Manually run npm run build, which should show the reason for the failure.