Create a AWS Lambda layer using Docker

859 views Asked by At

I am trying to follow the instructions on this page: How do I create a Lambda layer using a simulated Lambda environment with Docker? on a Windows 7 environment.

I followed all of these steps:

  • installed Docker Toolbox
  • created a local folder 'C:/Users/Myname/mylayer' containing requirements.txt and python 3.8 folder structure
  • run the following commands in docker toolbox:
    cd c:/users/myname/mylayer
    docker run -v "$PWD":/var/task "lambci/lambda:build-python3.8" /bin/sh -c "pip install -r requirements.txt -t python/lib/python3.8/site-packages/; exit"

It returns the following error:
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

I don't understand what I am doing wrong. Maybe something obvious (I'm a beginner) but I spent the whole day trying to figure it out and it is getting quite frustrating. Appreciate the help!

1

There are 1 answers

0
Scott On

I ran the following in Windows 10 Powershell and it worked

docker run -v ${pwd}:/var/task "amazon/aws-sam-cli-build-image-python3.8" /bin/sh -c "pip install -r requirements.txt -t python/lib/python3.8/site-packages; exit"