Skip to main content

Overview

The Formal Terraform Provider enables you to manage Connectors, Resources, Policies, Users, and all other Formal objects as infrastructure-as-code.

Installation

Add the provider to your Terraform configuration:

Authentication

Create an API key in the Control Plane:
  1. Navigate to API Keys
  2. Click Create API Key
  3. Name the key (e.g., “terraform-production”)
  4. Copy the key immediately
Set the key as an environment variable or Terraform variable:
Or in Terraform:

OIDC

Instead of an API key, the provider can authenticate with a workload’s OIDC token through an OIDC integration:

Keep Secrets Out of State

Set retrieve_sensitive_values = false on the provider. Terraform then doesn’t store sensitive values that the API returns, such as Connector API keys and machine role access tokens.
For secrets that you send to Formal, use write-only arguments. Terraform 1.11 and later sends them without storing them in state. Increment the matching _version argument to rotate the secret.
A native user can also read its secret from an environment_variable on the Connector or from a secret_manager. The secret then stays out of Terraform.

Examples

Full Production Stack

Resource Documentation

Full documentation for all resources: Core Resources: Integrations: Data Sources:

Example Repositories

Formal provides complete Terraform examples: Clone and customize for your needs:

Best Practices

Pin provider versions to avoid unexpected changes:
Use remote state backends (S3, Terraform Cloud) for team collaboration:
Parameterize configurations for reusability:
Use workspaces or separate state files for prod/staging/dev:
Protect production resources:

Importing Existing Resources

Bring existing Formal objects under Terraform management:
Get object IDs from the Control Plane or API.

Outputs

Export useful information:

Next Steps

Provider Docs

Complete Terraform provider documentation

Examples

Deployment examples on GitHub