This is a mess. I will edit it later
This is the command history to build a Lambda Layer in Python. I had to add a C compiler, Compile Python 3.9 with a specific requests module, and then upload to S3 and Add the Layer to Lambda function before I could use it but after all that, it worked.
[cloudshell-user@ip-10-2-31-49 packaging]$ history 100
============================================================================
1 sudo yum -y update
2 python -V
3 wget https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz
4 tar xvf Python-3.9.16.tgz
5 cd Python-3.9.16/
6 ./configure –enable-optimizations
7 sudo make altinstall
8 ls
9 ./configure –enable-optimizations
10 sudo yum groupinstall “Development Tools”
11 gcc –version
12 ./configure –enable-optimizations
13 sudo make altinstall
14 python -V
15 ls /usr/local/bin/
16 ls /usr/local/bin/python3.9
17 /usr/local/bin/python3.9 -V
18 alias python=’/usr/local/bin/python3.9′
19 python -V
20 gcc –version
21 pwd
22 cd ..
23 cd ~
24 ls
25 mkdir packaging
26 cd packaging/
27 python3.9 -m venv layer_package
28 source layer_package/bin/activate
29 pip install requests
30 pip install –trusted-host pypi.org –trusted-host pypi.python.org –trusted-host files.pythonhosted.org requests
31 pip config set global.trusted-host “pypi.org files.pythonhosted.org pypi.python.org” –trusted-host=pypi.python.org –trusted-host=pypi.org –trusted-host=files.pythonhosted.org
32 pip install requests
33 pip install –trusted-host pypi.python.org linkchecker
34 pip -V
35 pip install –trusted-host pypi.python.org requests
36 pip install –trusted-host files.pythonhosted.org –trusted-host pypi.org –trusted-host pypi.python.org requests
37 yum install openssl-devel
38 sudo yum install openssl-devel
39 cd /usr/src
40 deactivate
41 sudo yum install openssl-devel
42 ls
43 cd ~
44 ls
45 cd Python-3.9.16
46 ls
47 ./configure –enable-optimizations
48 ls /usr/local/bin/
49 ls /usr/local/bin/python3.9
50 rm -r /usr/local/bin/python3.9
51 sudo rm -r /usr/local/bin/python3.9
52 ls /usr/local/bin/python3.9
53 sudo make altinstall
54 python -V
55 cd ~/packaging/
56 python3.9 -m venv layer_package
57 source layer_package/bin/activate
58 pip install requests
59 deactivate
60 ls
61 mkdir python
62 cp -r layer_package/lib/python3.9/site-packages/* python/
63 zip -r lambda-layer-requests-python3.9-x86_64.zip python
64 ls
65 aws s3 ls
66 aws s3 mb csa-va-lambda-layers-python-requests
67 aws s3 mb s3://csa-va-lambda-layers-python-requests
68 aws s3 ls
69 ls
70 aws s3 cp lambda-layer-requests-python3.9-x86_64.zip s3://csa-va-lambda-layers-python-requests
71 ls
72 ls python/
73 ls python/urllib3
74 sudo rm -r python/urllib3
75 ls python/requests
76 sudo rm -r python/requests
77 pip install requests==2.28.2 -t ./python –no-user
78 pip3 install requests==2.28.2 -t ./python –no-user
79 ls python/
80 zip -r lambda-layer-requests-python3.9-x86_64-2.zip python
81 ls
82 aws s3 cp lambda-layer-requests-python3.9-x86_64-2.zip s3://csa-va-lambda-layers-python-requests