Deployment · Terraform

Manage your federation infrastructure as code

The official WunderGraph Terraform provider lets you define federated graphs, subgraphs, namespaces, and contracts in declarative HCL. Preview changes before applying. Full GitOps workflow for Cosmo Cloud resources.

Also available: AWS Fargate deployment module for production router deployments.

Available onFreeProEnterprise

The problem

Manual federation resource management does not scale

Clicking through a UI or running CLI commands to create federated graphs and subgraphs works for one person in one environment. It breaks down across teams, environments, and time.

Manual resource management causes configuration drift

Clicking through Studio or running wgc commands to create federated graphs and subgraphs does not scale. Environments diverge. Changes are hard to review and impossible to audit.

No change preview means risky deployments

Applying infrastructure changes without a preview step introduces risk. Teams need to see exactly what will change before it changes, especially in production federation infrastructure.

Team collaboration on infrastructure requires tooling

Without infrastructure as code, only one person can safely change federation resources at a time. Code review, approval workflows, and audit trails require version-controlled configuration.

Our solution

Federation infrastructure as code

The Cosmo Terraform provider brings standard IaC practices to GraphQL federation. Define resources in HCL, version them in Git, review them in pull requests, and apply them consistently across environments.

How it works

  1. Configure the wundergraph/cosmo Terraform provider with your Cosmo Cloud API key.

  2. Define your federation resources in HCL: namespaces, federated graphs, subgraphs, and contracts.

  3. Store your Terraform configurations in version control alongside your application code.

  4. Run terraform plan to preview what changes will be applied before executing them.

  5. Run terraform apply to create or update resources in Cosmo Cloud.

  6. Integrate with CI/CD to automate schema publishing and infrastructure provisioning on merge.

Every change reviewed, versioned, and auditable.

Terraform Provider

Before & After

Before TerraformWith Terraform
Manual CLI or Studio UI configuration for each resourceDeclarative configuration files in version control
Configuration drift between dev, staging, and productionIdentical infrastructure across all environments
No change tracking for federation resourcesFull version control history for every change
Risky deployments with no preview of changesPreview with terraform plan before applying

How the Cosmo Terraform provider works

01
Official provider in Terraform Registry.

Configure provider

Add the wundergraph/cosmo provider to your Terraform configuration and supply your Cosmo Cloud API key. The provider is available in the Terraform Registry.

02
All Cosmo resources supported.

Define resources

Write HCL to define your namespaces, federated graphs, subgraphs, feature flags, and contracts. Use variable files to manage environment-specific values.

03
Preview before applying.

Plan

Run terraform plan to see exactly which resources will be created, updated, or deleted. Review changes in a pull request before they reach production.

04
State tracking prevents drift.

Apply

Run terraform apply to provision or update resources in Cosmo Cloud. Terraform tracks state, detects drift, and ensures resources match your declared configuration.

Provider capabilities

Infrastructure as code for federation

Standard Terraform workflows applied to GraphQL federation resources.

State management

Terraform tracks the state of every Cosmo resource. Drift detection alerts you when resources diverge from configuration. Remote backends (S3, GCS) store state for team collaboration.

CI/CD integration

Run terraform plan in CI on pull requests. Apply on merge. Works with GitHub Actions, GitLab CI, Jenkins, and Terraform Cloud.

AWS Fargate module

A dedicated Terraform module deploys Cosmo routers to AWS Fargate across three availability zones, with optional TLS via a Route53-managed domain (HTTPS mode).

Multi-environment support

Use separate variable files and Cosmo namespaces for dev, staging, and production. Run terraform apply per environment in your pipeline.

Manage federation infrastructure as code

Official provider. Terraform Registry. Preview every change before it applies.

FAQ

Terraform provider questions

Read more in the Terraform provider documentation.