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?

1
  • 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 Commented Sep 10, 2018 at 20:56

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.