Skip to content

In this guide, we’ll deploy a router endpoint to Google Cloud Run with Terraform, following an approach inspired by Apollo’s official deployment guide.

Notifications You must be signed in to change notification settings

mel-cdn/apollo-graphos-router-google-cloud-run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apollo GraphOS Router as Cloud Run Service

📖 Overview

In this guide, we’ll deploy a router endpoint to Google Cloud Run with Terraform, following an approach inspired by Apollo’s official deployment guide.


✨ Highlights

  • Apollo GraphQL Apollo GraphQL
  • Docker Containerization with Docker
  • GCP Google Cloud Platform (GCP)
  • Terraform Infrastructure as Code via Terraform
  • Azure DevOps Pipeline Automated CI/CD using Azure DevOps Pipelines (Terraform validation + deployment)

🚀 Getting Started

Prerequisites

Before proceeding, ensure the following are installed and configured:

  • Google Cloud Project
  • Terraform
  • Apollo GraphQL Account
    • Create a free Apollo GraphQL Account
    • Create a Graph (Supergraph)
    • Store these values to your GCP Secret Manager
      • apollo-api-key -> APOLLO_KEY
        • e.g. service::
      • apollograph-id -> APOLLO_GRAPH_REF (e.g. <graph-name>@current)
    • This repository provides the infrastructure and pipeline setup needed to deploy and publish a Subgraph to an Apollo Supergraph

Authenticate Google Cloud Credentials

# Authenticate your GCP account
gcloud init

# Set your default project
gcloud config set project <my-project-id>

# Configure application default credentials (for SDKs and integrations)
gcloud auth application-default login

Installation

# Clone repository
git clone https://github.com/mel-cdn/apollo-graphos-router-google-cloud-run.git
cd apollo-graphos-router-google-cloud-run

Deployment via Terraform

# Move to Terraform path
cd ./terraform

# Initialize Terraform with your remote backend
terraform init --backend-config="bucket=<terraform-state-gcs-bucket>"  

# Format Terraform configuration files
terraform fmt

# Validate configuration
terraform validate

# Generate execution plan
terraform plan \    
  -var="project_prefix=$(GCP_PREFIX)" \
  -var="environment=$(ENVIRONMENT)" \
  -var="region=$(GCP_REGION)" \
  -var="root_domain_name=$(ROOT_DOMAIN_NAME)" \
  -out=tfplan

# Apply changes
terraform apply tfplan

Publish Subgraph to Supergraph

APOLLO_KEY=<APOLLO_KEY> rover subgraph publish <APOLLO_GRAPH_REF> \
  --schema="./tmp/schema.graphql" \
  --name="subgraph-name" \
  --routing-url="https://<subgraph-graphql-api-url>/graphql"

About

In this guide, we’ll deploy a router endpoint to Google Cloud Run with Terraform, following an approach inspired by Apollo’s official deployment guide.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published