```code bash sudo yum update -y sudo su cd /home/ssm-user sudo yum install gcc bzip2-devel ncurses-devel gdbm-devel xz-devel sqlite-devel openssl-devel tk-devel uuid-devel readline-devel zlib-devel libffi-devel
## Install Python 3.9
```code bash
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar -xJf Python-3.9.0.tar.xz
cd Python-3.9.0
./configure --enable-optimizations
make altinstall
export PATH=$PATH:/usr/local/bin
-needs to be updated with creation of virtual environment-
```code bash cd /home/ssm-user python3 -m venv tutorial-env source tutorial-env/bin/activate
## install software for layer
```code bash
cd tutorial-env
mkdir my-lambda-layer &&
cd my-lambda-layer
mkdir -p aws-layer/python/lib/python3.9/site-packages
pip3 install beautifulsoup4 --target aws-layer/python/lib/python3.9/site-packages
This concludes the PIP-installation now we need to create the zip file.
```code bash cd aws-layer zip -r9 lambda-layer.zip .
Don't forget to include the "." at the end.
After zipping the packages it will have the name “lambda-layer.zip”
## Upload the zip file to a lambda layer using AWS CLI.
To create the lambda layer automatically using the AWS CLI you can use the command below:
``` code bash
aws lambda publish-layer-version \
--layer-name Data-Preprocessing \
--description "My Python layer" \
--zip-file fileb://lambda-layer.zip \
--compatible-runtimes python3.9
code bash
cd .. && cd .. && cd .. && rm -rf tutorial-env
OR------------------
from PIL import Image
def lambda_handler(event, context): # TODO implement return { 'statusCode': 200, 'body': json.dumps('Hello from Lambda!') }