Secure Google Cloud Functions with API Gateway

Photo by Sara Julie on Unsplash — This glass probably need an API Gateway

Intro

Prerequisite

Create Google Cloud Functions

mkdir listSmoothies
mkdir orderSmoothie
touch listSmoothies/main.py
touch orderSmoothie/main.py
touch listSmoothies/requirements.txt
touch orderSmoothie/requirements.txt
flask==1.1.2
gcloud functions deploy listSmoothies --region=europe-west2 --trigger-http --entry-point listSmoothies --runtime python38 --no-allow-unauthenticated
https://europe-west2-YOUR-PROJECT.cloudfunctions.net/listSmoothies
flask==1.1.2
gcloud functions deploy orderSmoothies --region=europe-west2 --trigger-http --entry-point orderSmoothies --runtime python38 --no-allow-unauthenticated
https://europe-west2-YOUR-PROJECT.cloudfunctions.net/orderSmoothies

Create the API

gcloud services enable apigateway.googleapis.com 
gcloud services enable servicemanagement.googleapis.com
gcloud services enable servicecontrol.googleapis.com
Name : SmoothAPIID : smoothapi
Api Config Name : Medium Config
Select “Cloud Function Invoker”
Name : SmoothAPI Gateway

Deployment

Access the API

Huuuuurrrrayyyyyy!! Instagramable smoothies!!

Rate Limit & Secure the API with API Keys

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store