Skip to content
ferng edited this page Jul 29, 2020 · 2 revisions

Serverless

Install Serverless

npm install -g serverless

Create new service

  • In the directory where you develop the service
serverless create --template aws-nodejs --path my-service

Remote

Create IAM user

  • Go to IAM page > Users > new user
  • Grant programmatic access
  • Attach existing policies directly > AdministratorAccess
  • Ignore tags
  • Create User

Configure serverless with user

serverless config credentials --provider aws --key xxxxxxxxxxxxxx --secret xxxxxxxxxxxxxx

Configure region

vi serverless.yml

  stage: dev                                                                    
  region: eu-west-2                               ```

Deploy to aws

serverless deploy -v

# which will deploy everything and give you the endpoint
endpoints:
  GET - https://v69b1ygn03.execute-api.eu-west-2.amazonaws.com/dev/users/create
  • and test it
serverless invoke -f hello -l

Offline

  • Configure npm
npm init
  • Install offline serverless
npm install serverless-offline --save-dev

# and configure it
vi serverless.yml

# add these lines
plugins:
  - serverless-offline
  • Run it locally
serverless offline start

#this will then give you the available endpoint
http://localhost:3000/dev/users/create

Clone this wiki locally