Skip to content

Add a new route

Patrick MacMurchy edited this page Mar 19, 2019 · 3 revisions

To add a new route update the template.yaml

This would be nested under Resources:

Resources:
  [...]
  CensusFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: census/
      Handler: census
      Runtime: go1.x
      Tracing: Active # https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html
      Events:
        SomeEventName:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /census
            Method: GET
      Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
        Variables:
          PARAM1: "foobar"  

Add a new folder to match the path - in this case census (in your root) and add a main.go.

Update the Makefile to include building the new directory:

GOOS=linux GOARCH=amd64 go build -o census/census ./census

Make sure to restart your make dev (and maybe make local?)

Clone this wiki locally