Terraform Provider for GraphQL Federation | Cosmo by WunderGraph - WunderGraph
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.
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
- Configure the wundergraph/cosmo Terraform provider with your Cosmo Cloud API key.
- Define your federation resources in HCL: namespaces, federated graphs, subgraphs, and contracts.
- Store your Terraform configurations in version control alongside your application code.
- Run terraform plan to preview what changes will be applied before executing them.
- Run terraform apply to create or update resources in Cosmo Cloud.
- Integrate with CI/CD to automate schema publishing and infrastructure provisioning on merge.
Every change reviewed, versioned, and auditable.
Before & After
| Before Terraform | With Terraform |
|---|---|
| Manual CLI or Studio UI configuration for each resource | Declarative configuration files in version control |
| Configuration drift between dev, staging, and production | Identical infrastructure across all environments |
| No change tracking for federation resources | Full version control history for every change |
| Risky deployments with no preview of changes | Preview with terraform plan before applying |
Supported resources
What the provider manages
Namespaces, Federated Graphs, Subgraphs, Monographs, Feature Flags, Feature Subgraphs, Contracts, Router Tokens
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
Where can I find the Cosmo Terraform provider?
What Cosmo resources can the provider manage?
What version of Terraform is required?
Does the provider work with Terraform Cloud?
Is there a module for deploying routers to AWS Fargate?
How do I manage environment-specific configurations?
Where can I find example configurations?
Read more in the Terraform provider documentation.