aws, serverless, systems, vue,

Serverless Deploy to AWS – simple naming convention

Follow Nov 10, 2017 · 2 mins read
Serverless Deploy to AWS – simple naming convention
Share this

Serverless deploy and remove commands to keep things tidy and using and stages for separating API versioning (when you’re getting into some inelegant developer experiences with mixing cloud and testing out what different blockchain tech does).  I’m lucky enough to control the backend and front-end for this particular task, so I like to keep version numbers in there.  A workaround if needed is to do redirection to the most recent API version – YMMV

With reference to serverless.yml config file.

DynamoDB Table name

DynamoDB table = {service name}-{stage}

  environment:
    DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}

If you wanted to hard code it, this is where you’d do it.  But for this blog entry the DynamoDB table is iMyloMylo-Task-v0

API Version

API version = stage

provider:
  name: aws
  runtime: nodejs4.3
  memorySize: 128
  region: ap-southeast-2
  stage: v0

URL for your API: https://b4ury4mee1.execute-api.ap-southeast-2.amazonaws.com/v0/

API URL

URL Path = path

functions:
  create:
    handler: task/create.create
    events:
      - http:
          path: task
          method: post
          cors: true

  list:
    handler: task/list.list
    events:
      - http:
          path: task
          method: get
          cors: true

  get:
    handler: task/get.get
    events:
      - http:
          path: task/{id}
          method: get
          cors: true

endpoints:

  POST – https://b4ury4mee1.execute-api.ap-southeast-2.amazonaws.com/v0/task

  GET – https://b4ury4mee1.execute-api.ap-southeast-2.amazonaws.com/v0/task

  GET – https://b4ury4mee1.execute-api.ap-southeast-2.amazonaws.com/v0/task/{id}

 

Setting the project name & region for easy reference when in AWS Console

service: iMyloMylo-Task

frameworkVersion: ">=1.1.0 <2.0.0"

provider:
  name: aws
  runtime: nodejs4.3
  memorySize: 128
  region: ap-southeast-2
  stage: v0

 

Serverless Deploy & Remove housekeeping

So when you’re testing out a bunch of things and it’s really cheap to deploy to the cloud and make a bunch of branches in your repo, you’ll want to delete all your mess.

When you

serverless deploy

you will inevitably want to

serverless remove

The naming convention between branches will help you track what you have missed when it comes time to tear down.

 

Written by