Simple proxy server in Google Cloud
Testing a simple function app setup in Google Cloud with Terraform. Can be used to proxy requests.
- Clone the project
cd gcp-proxy & npm install
- Start typescript compilation
npm run watch
- In another shell, start the local server
npm start
- Get a free Google Cloud account: https://console.cloud.google.com/freetrial
- Create new project, add project's ID to
terraform/variables.tf
. Update alsoterraform/modules/api/openapi.yml
- Enable following APIs from "APIs & Services"
- Cloud Build
- Cloud Run
- Cloud Functions
- Identity-Aware Proxy
- Enable necessary services
gcloud services enable apigateway.googleapis.com
gcloud services enable servicemanagement.googleapis.com
gcloud services enable servicecontrol.googleapis.com
- Select one of the supported regions for API gateway, and put it to
terraform/variables.tf
. Update alsoterraform/modules/api/openapi.yml
.
asia-northeast1
australia-southeast1
europe-west1
europe-west2
us-east1
us-east4
us-central1
us-west2
us-west3
us-west4
-
Check your service account id (or create one) and put it to
terraform/variables.tf
-
Initialize terraform
cd terraform
terraform init
-
Plan the deployment
terraform plan
-
Deploy
terraform apply
-
Create an API key in Google Cloud console "API Keys" and restrict it to proxy-api only.
-
Test your api by querying your url with
x-api-key
header. Checkterraform/modules/api/openapi.yml
for full API documentation
MIT - See LICENSE