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:

  1. Create a New Cloud9 Environment: Start with a fresh environment to avoid conflicts with existing configurations.
  2. 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:

  1. 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
    
  2. Extract the downloaded archive:
    sudo tar xzf Python-3.9.16.tgz
    
  3. Navigate to the extracted directory and configure the source code:
    cd Python-3.9.16
    sudo ./configure --enable-optimizations
    
  4. Compile and install Python 3.9:
    sudo make altinstall
    
  5. 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:

  1. Create a temporary directory:
    cd lambda
    mkdir -p temp/python
    cd temp/python
    

Installation:

  1. Install Snowflake Connector for your desired Python version:
    pip install snowflake-connector-python -t .
    
  2. Create the Lambda Layer package:
    cd ..
    zip -r9 ../snowflake-connector-python39.zip .
    

Uploading and Using the Layer:

  1. Navigate to the Lambda service in the AWS console.
  2. Select "Layers" in the menu and click "Create Layer."
  3. Name your Layer (e.g., snowflake-connector-python39) and select the compatible runtimes (e.g., python3.9).
  4. Upload the zip file created in step 2.
  5. 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.

Comments


  1. Very 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

    ReplyDelete

Post a Comment

Popular posts from this blog

Snowflake and Geospatial