This repository is showing the steps to create lambda function for extracting the data from xml file provided in the assignment of the Python Engineer role in Steel-eye company.
Steps:
- Create and activate the virtual environment named 'steeleye'.
virtualenv -p /usr/bin/python3.6 steeleye
cd steeleye
source bin/activate
- go to site-packages directory
cd lib/python3.6/site-packages
- Install the requirements from requirements.txt
pip install -r requirements.txt
-
Create a file lambda_fucntion.py in the current working directory and define your function in this file.(Unzip steeleyr.zip from this repository and use lambda_function.py file in your codes)
-
Create a zip file named ‘lambda_function.zip’ with the following directories/files in the same directory.
- certifi(dir)
- chardet(dir)
- _distutils_hack(dir)
- idna(dir)
- requests(dir)
- urllib3(dir)
- distutils-precedence.pth(file)
- lambda_function(file)
-
Log in to the AWS console and access the lambda service.
-
Create a new function with the name ‘Steeleye’. Import the zip file created in step 5 from Actions button. After the successful import content of the zip file should be visible in the Environment pane, visible towards the left side.
-
Go to Runtime settings by scrolling down, select runtime as ‘Python 3.6’, and save the changes.
-
Go to Basic Settings by further scrolling down the screen and increase the Memory(MB) to 4096 and Timeout to 5 mins.
-
Create a bucket in S3 services with the name of ‘steeleyetest3424’ and save the bucket.
-
Deploy the function by clicking on the ‘Deploy’ button.
-
Test the function by clicking on the ‘Test’ button.
-
Once the test is successful, open the S3 bucket, access the 'tmp' directory within the S3 bucket, and download datafile.csv to get the records mentioned in the assignment. (datafile.csv file has 0.5 Million records. Unzip datafile.zip file to access datafile.csv file).