codefordenver / shift-api

1 stars 0 forks source link

WIP: Add new route on lambda #34

Closed pmm4654 closed 5 years ago

pmm4654 commented 5 years ago

To add a new route update the template.yaml

  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?)