2

In a handler of mine, I open a .mmdb file for doing geo lookups. In my package, I use ./ notation to reference the file since the handler and file are in the same directory. Now that I want to deploy the function using serverless, I've included the file within the include block in my serverless.yml file. Based on the package size that I'm seeing, the file is being uploaded, however I'm getting the error

open ./GeoLite2-City.mmdb: no such file or directory 

when running the lambda. What is the proper way to get the location of the file from within my lambda?

mycellius
  • 568
  • 1
  • 5
  • 28
  • 1
    AWS exports a variable called `LAMBDA_TASK_ROOT` which points to the source of your deployed code. You should use that as base path – yorodm Sep 10 '18 at 20:56

1 Answers1

0

I solved my problem by listing the contents of the directory that I was using in my lambda, using the code found in this answer: List directory in Go. After doing so I realized that I was in the root directory of the entire folder that I uploaded, not the directory of the specific package I was running the code from (containing main.go)

mycellius
  • 568
  • 1
  • 5
  • 28