AWS Lambda Layers Python | Snowflake-lambda-layer

Published: 08 October 2021
on channel: Knowledge Amplifier
7,351
89

In this video , I discussed about Lambda Layer , which is kind of an external library that can be directly included, and used in the Lambda function.
Hope this video will be helpful to you!

Lambda Layer Creation Code:
-----------------------------------------------
sudo apt-get update
sudo apt install python3-virtualenv
virtualenv snowflake_test
source snowflake_test/bin/activate
python3 --version
sudo apt install python3-pip
python3 -m pip install --upgrade pip
sudo apt-get install -y libssl-dev libffi-dev
mkdir -p lambda_layers/python/lib/python3.8/site-packages
cd lambda_layers/python/lib/python3.8/site-packages
pip install -r https://raw.githubusercontent.com/sno... -t .
pip install snowflake-connector-python==2.3.10 -t .
cd ~/lambda_layers
sudo apt install zip
zip -r snowflake_lambda_layer.zip *

The zip used in the lambda layer can be downloaded form this link also:
https://drive.google.com/file/d/1ZG58...

Lambda Function used:
--------------------------------------
import snowflake.connector as sf

def run_query(conn, query):
cursor = conn.cursor()
cursor.execute(query)
cursor.close()

def lambda_handler(event, context):
user=""
password=""
account="";
database=""
warehouse=""
schema=""
role=""
conn=sf.connect(user=user,password=password,account=account);


statement_1='use warehouse '+warehouse;
statement3="use database "+database;
statement4="use role "+role;
run_query(conn,statement_1)
run_query(conn,statement3)
run_query(conn,statement4)
sql_query_table_creation = "CREATE OR REPLACE TABLE test_table(col1 integer, col2 string)"
run_query(conn, sql_query_table_creation);
sql_query_data_ingestion="INSERT INTO test_table(col1, col2) VALUES (123, 'test string1'), (456, 'test string2')"
run_query(conn, sql_query_data_ingestion);


Check this playlist for more AWS Projects in Big Data domain:
   • Demystifying Data Engineering with Cloud C...  


On this page of the site you can watch the video online AWS Lambda Layers Python | Snowflake-lambda-layer with a duration of hours minute second in good quality, which was uploaded by the user Knowledge Amplifier 08 October 2021, share the link with friends and acquaintances, this video has already been watched 7,351 times on youtube and it was liked by 89 viewers. Enjoy your viewing!