Step 1: Set Up Your Environment

Ensure you have the following tools installed:

Step 2: Create a Directory Structure for the Lambda Layer

mkdir -p lambda-layer/python/lib/python3.9/site-packages

Step 3: Install the Packages

Navigate to the lambda-layer directory and install the required packages into it:

cd lambda-layer
pip3 install pandas numpy ccxt -t python/lib/python3.9/site-packages/

Step 4: Package the Layer

Package the Lambda layer:

zip -r atlas_trade_layer_one_dependencies.zip .

Step 5: Upload the Layer to AWS Lambda

Use the AWS CLI to publish the layer:

aws lambda publish-layer-version \\
  --layer-name atlas-trade-layer-one-dependencies \\
  --zip-file fileb://atlas_trade_layer_one_dependencies.zip

Step 6: Reference the Layer in Your Lambda Function

Once the layer is uploaded, AWS will provide an ARN (Amazon Resource Name) for the layer. You can use this ARN to associate the layer with your Lambda function.

In your serverless.yml (or AWS Console / AWS SAM / CloudFormation), include the layer ARN to link your Lambda function to the layer:

layers:
  - arn:aws:lambda:<REGION>:<ACCOUNT_ID>:layer:python-dependencies-layer:<VERSION>

Note: