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

  1. Connect to your Google Cloud Console : https://console.cloud.google.com/api-gateway/api
gcloud services enable apigateway.googleapis.com 
gcloud services enable servicemanagement.googleapis.com
gcloud services enable servicecontrol.googleapis.com

API Part

Name : SmoothAPIID : smoothapi

API Config Part

  1. Keep “Create new API config”
Api Config Name : Medium Config
Select “Cloud Function Invoker”

Gateway part

Name : SmoothAPI Gateway

Deployment

Access the API

Huuuuurrrrayyyyyy!! Instagramable smoothies!!

Rate Limit & Secure the API with API Keys

--

--

--

Future Unicorn Founder — Using tech for good

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Developing our own Operating System (Part 08)

Battle Tested: How We Built and Master Our CI/CD Pipeline

CI/CD Easy Way With GitLab

Improve FHIR Search — GSoC 2020 with OpenMRS

HOW TO MINT NFTS ON PROFESSOR.FINANCE

Definition of Logic Gates | Positive and Negative Logic | Truth table | Types of Logic Gates

✨Harmony Launcher NFTO Whitelist on Genpad🔥

Building and Deploying C# Azure Functions using Multi-Stage Pipelines in Azure DevOps

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
Beranger Natanelic

Beranger Natanelic

Future Unicorn Founder — Using tech for good

More from Medium

Reduce DB upgrade downtime to less than 10 minutes using DMS on Google Cloud

Create your own API in Google Cloud with Terraform

Building a Scalable and Audit-Ready Event-Driven Application on Google Cloud Platform

Google Cloud Artifact Registry with GitHub Actions