Deploying an AWS Lambda function with the Serverless Framework on Windows

Published 10-31-2018 10:02:55

Like many other people before me, I tried to deploy my Golang Lambda function on Windows and have run into permissions problems. First, it was when I was using SAM and then again when I started to use the Serverless framework. I would setup my new Serverless-based app, deploy, hit the endpoint and get this dreaded return message…

fork/exec /var/task/bin/main: permission denied: PathError null

…or some such related error.

Essentially what was happening is that Windows does not set the proper permissions on files that are inside of the .zip file that gets uploaded to S3, and Lambda is unable to open it to run it. There are a few workarounds that involve you using a 3rd-party script to manually zip the files before they get sent off the S3. The problem with this solution, if you’re using Serverless, is that you can’t incorporate that into the deployment process.

What I ended up doing was using Ubuntu for Windows, installing Serverless and Go within that environment and using all of my serverless commands within there. What this gives me is the ability to continue to use Windows as my development environment with my IDE, and just have a cmder window open to deploy Serverless applications as if I’m a Ubuntu user.