This repository provides a shell script to create a Lambda layer using Docker. The script builds a Docker image based on the provided Dockerfile and requirements.txt, and then runs a Docker container to create the layer. Finally, it moves the layer.zip file to the specified directory.
- Docker installed and properly configured on your system.
-
Clone or download this repository to your local machine.
-
Open the
create_layer.sh
file in a text editor. -
Set the
DIRECTORY
variable to the path where yourDockerfile
andrequirements.txt
files are located. -
Set the
LAYER_NAME
variable to the name you want to give your layer by default, it'slayer
. -
Add all the required pachages in
requirements.txt
and save it. -
Save the changes.
-
Open a terminal or command prompt and navigate to the directory where the
create_layer.sh
script is located. -
Make the script executable by running the command:
chmod +x create_layer.sh
. -
Run the script:
./create_layer.sh
. -
The script will build the Docker image, run the container to create the layer, move the
layer.zip
file to the specified directory, and clean up by removing the Docker image. -
After running the script, you should find the
layer.zip
file in the specified directory. You can then upload it to AWS Lambda as a layer and attach it to your Lambda functions as needed.
-
Please ensure that you have Docker installed and configured properly on your system before running the script.
-
Make sure to include the necessary
requirements.txt
file in the directory specified by theDIRECTORY
variable. The script will install the Python packages listed inrequirements.txt
and include them in the Lambda layer. -
You may need to modify the Dockerfile or requirements.txt based on your specific requirements.