Creating an AWS serverless lambda project in Golang

29 views Asked by At

I'm trying to build an API in Golang leveraging Serverless and AWS, I have a folder we'll call apiOne, in that folder I have four files

  • main.go
  • wf.go
  • wi.go
  • apiTranslator.go

In my main.go file, I call functions from the wf.go & wi.go files.

  • GetWFForecasts
  • GetWSForecasts

My serverless.yml file has one function that calls the main.go file

  forecasts:
    handler: bin/forecasts
    name: ${self:custom.stackPrefix}-forecasts
    package:
      include:
        - 'src/*'
    description: "Test For API"
    memorySize: 256
    timeout: 30
    events:
      - http:
          path: /forecasts
          method: get

I have a Makefile so that it builds for the serverless function

env GOOS=linux go build -ldflags="-s -w" -o bin/forecasts src/main.go

but when I run make I get the following error

env GOOS=linux go build -ldflags="-s -w" -o bin/forecasts src/main.go
# command-line-arguments
src/main.go:58:24: undefined: GetWFForecasts
src/main.go:59:22: undefined: GetWSForecasts
make: *** [build] Error 1

I've been fighting with this for a few days now, I have some experience working with AWS serverless using Python but I've been fighting to get the working with Go. I've researched a ton and haven't found anything to help. This isn't simply a "how to compile in go" question, I'm trying to figure out how to use the compiled program in a lambda function. Any advice regarding this would be greatly appreciated

0

There are 0 answers