- Create a new AWS Lambda function (arm64), make it public, and copy this code into
lambda_function.py
- Set the environment variables
- Add jwt library dependency
- Click
Deploy
and then clickTest
Go to Console->Configuration->Env. and add inputs:
APS_clientID, APS_secretID, SSA_oxygenID, kid, private_key
Similar to this CLI command:
export APS_clientID="your_client_id"
export APS_secretID="your_secret_id"
export SSA_oxygenID="your_oxygen_id"
export kid="your_key_id"
export private_key="your_private_key"
export SCOPE="data:read data:write"
This seperates future source code changes, from the jwt library dependency, without uploading new package.zip files constantly.
You need to create a python library dependency zip file first, and then add it to the function as a layer.
- a. Create the zip file
mkdir my-lambda-function
cd my-lambda-function
pip3 install \
--platform manylinux2014_aarch64 \
--target=python/lib/python3.12/site-packages \
--implementation cp \
--python-version 3.12 \
--only-binary=:all: --upgrade \
PyJWT requests cryptography
zip -r python_dependencies.zip python
- b. Create a new layer Lambda function -> 'layer'
- c. Upload the python_dependencies.zip file into the layer
- d. choose ARM64 and Python3.12 platform dependencies, use name 'pyArmLibs'
- e. Go back to Function and 'Add Layer', select 'pyArmLibs' and v1.