Today we will learn on how to import external libraries in AWS Lambda function and call the api functions
Steps:
- Create an empty AWS Lambda function
- Download geopy library from PyPi
- Link: https://pypi.org/project/geopy/
- extract the geopy folder in a separate location from the above downloaded zip
- delete the zip and the rest. we just need the geopy folder
- Download geographiclib library
- Link: https://pypi.org/project/geographiclib/
- extract the geographiclib folder in a separate location from the above downloaded zip
- delete the zip and the rest. we just need the geographiclib folder
- Make a zip file that combines both the above two downloaded libraries folders
- Import/upload the zip file in our function
- Import the geopy library
- Write the code to calculate the distance between two cities (shown in the picture below)
- Run the function
- If you are running for the first time, it will ask you to create a test event. give a name for the test event and hit execute.
- You will see the result of the lambda function in your execution panel
No comments:
Post a Comment