Terraform Provider
© 2026 Sonrai Security. All rights reserved.
Overview
The Sonrai Terraform provider lets you manage Cloud Permissions Firewall (CPF) configuration as code. Instead of configuring controls by hand in the Sonrai web app, you declare them in Terraform, review changes in a plan, and keep the state of your controls in version control.
A single terraform apply stages your control changes, submits them, deploys the generated CloudFormation template, and confirms the rollout finished.
The provider, its documentation, and a complete worked example are available in the public terraform-provider-sonrai repository on GitHub.
What You Can Manage
The provider includes resources for:
- Disabled services and protected services (with exemptions) per account
- Identities exempt from whole classes of control at a scope
- Region controls per account
- Just-In-Time (JIT) Access configuration at a scope
- Submitting staged changes, and resetting an organization's controls back to staged
Data sources read values from the platform rather than copying them from the console, including suggested exemptions, available JIT entitlements, and the account the CloudFormation template deploys into.
You can also import an existing CPF deployment, so controls you've already configured in the web app can be brought under Terraform.
Where to Find It
- Source, examples, and guide: github.com/sonraisecurity/terraform-provider-sonrai. Start with the
examples/completemodule, which covers the whole cycle. - Terraform Registry: sonraisecurity/sonrai —
terraform initdownloads and verifies the provider. Per-resource reference documentation is published here. - OpenTofu Registry: the same provider and configuration work unchanged with OpenTofu.
Before You Start
You need:
- Terraform 1.5 or later, or OpenTofu 1.6 or later
- A Sonrai API token issued to an App identity with write scope. See Apps to create one.
- AWS credentials for the account the CPF template deploys into, if you want the same apply to deploy the CloudFormation stack
Submitting through the provider covers every change staged under the root scope, including changes staged from the web app. Read the repository README before your first apply — it explains how submissions, removals, and organization resets behave.