- Click this link to download Python
- Download and install Node Js
- Download and run the AWS CLI MSI installer
Install the serverless CLI via NPM:
npm install -g serverless
Once AWS CLI is installed, configure AWS CLI with AWS Access Key ID and AWS Secret Access Key.
aws configure
First, create Python virtual environment for packages installation (Windows OS)
python -m venv env
Once created activate it through the below command (Windows OS)
env\scripts\activate
Install all python requirements via PIP
pip install -r requirements.txt
Install node modules via NPM
npm i
Find Google API Key in your email. Replace this provided API Key (Or your Own Google API Key) in serverless.yaml under function section and in Trip function replace with original one.
functions:
TripFare:
handler: src/api/trip_fare.lambda_handler
layers:
- Ref: PythonRequirementsLambdaLayer
environment:
API_KEY: <API-Key> # Its for demo purpose, In real case all envrionment variables are in seperate file which is not a part of git repository
package:
patterns:
- ./src/api/trip_fare.py
iamRoleStatementsName: TripFare-policy-sls-${self:provider.region}-${self:provider.stage}
events:
- http:
path: trip/fare
method: get
cors: True
serverless deploy
- Use this link to get APIs collection. https://www.getpostman.com/collections/853aa642ec5ec96cfdc8
- After this set baseUrl environment variable to your one.