Installing Higher Python Versions on AWS Cloud9 and Creating Lambda Layers for Snowflake Connector
This blog post addresses two critical aspects for developers working with AWS Cloud9 and Lambda functions:
1. Installing Higher Python Versions on Cloud9
This section guides you through the process of installing a specific version of Python (3.9 in this example) on your Cloud9 environment, ensuring compatibility with dependencies like urrlib3 >= 2.0.0.
2. Creating Lambda Layers for Snowflake Connector with Different Python Versions
Learn how to build a Lambda Layer containing the Snowflake connector, enabling its use in your Lambda functions regardless of the default Python version on your Cloud9 environment.
Installing Python 3.9 on Cloud9
Preparation:
- Create a New Cloud9 Environment: Start with a fresh environment to avoid conflicts with existing configurations.
- Update System Dependencies: Ensure compatibility with Python 3.9 by running the following commands:
sudo yum remove openssl-devel
sudo yum install gcc openssl11-devel bzip2-devel libffi-devel
Installation:
- Download Python 3.9:
- Visit the official Python download page or use the following command:
wget https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz - Extract the downloaded archive:
sudo tar xzf Python-3.9.16.tgz - Navigate to the extracted directory and configure the source code:
cd Python-3.9.16 sudo ./configure --enable-optimizations - Compile and install Python 3.9:
sudo make altinstall - Set Python3 as the default version:
alias python='python3.9' alias pip='pip3.9'
Permanently save these aliases by adding them to your shell configuration file (e.g., ~/.bashrc).
Creating a Lambda Layer for Snowflake Connector
Preparation:
- Create a temporary directory:
cd lambda mkdir -p temp/python cd temp/python
Installation:
- Install Snowflake Connector for your desired Python version:
pip install snowflake-connector-python -t . - Create the Lambda Layer package:
cd .. zip -r9 ../snowflake-connector-python39.zip .
Uploading and Using the Layer:
- Navigate to the Lambda service in the AWS console.
- Select "Layers" in the menu and click "Create Layer."
- Name your Layer (e.g., snowflake-connector-python39) and select the compatible runtimes (e.g., python3.9).
- Upload the zip file created in step 2.
- When creating your Lambda function, add the Snowflake connector Layer to provide access to the connector libraries.
Conclusion
This blog post provided detailed instructions for installing specific Python versions on Cloud9 and creating versatile Lambda Layers for the Snowflake connector. By following these steps, you can ensure compatibility and access to necessary libraries within your Cloud9 and Lambda environments.
Additional Notes:
- This guide used Python 3.9 as an example. Adapt the commands to install your desired version of Python.
- Automate the Lambda Layer creation process for increased efficiency using the AWS CLI.
ReplyDeleteVery good article . Thanks for sharing.
Snowflake Training
Snowflake Training in Hyderabad
Snowflake Online Training
Snowflake Online Training Hyderabad
Snowflake Training Online
Snowflake Training in Ameerpet
Snowflake Training Institute in Hyderabad