Terraform Provider
OpenTremor-terraform-provider lets platform and organization admins manage the runtime configuration listed below as code. It manages resources through the REST API; it does not cover every setting available in Platform Admin or Organization Settings.
It does not provision OpenTremor itself. Containers, Helm charts and MongoDB are Deployment’s job. This provider configures an instance that is already running. Deploy the instance, then point Terraform at it.
Resources
Section titled “Resources”| Resource | What it manages |
|---|---|
opentremor_organization | Tenants — creation, plan tier, lock state, org-wide 2FA policy |
opentremor_platform_settings | Instance-wide runtime settings (logging, registration, retention, GitHub) |
opentremor_pricing | The metered price list |
opentremor_organization_settings | An organization’s LLM spend cap, report-link TTL, sign-in methods, agent access, agent-injection settings, code suggestions and support assistant |
opentremor_api_key | Service accounts, with role, IP allowlist and permission scopes |
opentremor_org_role | Custom organization roles — a named set of permissions, assignable by id |
opentremor_sso_connection | An organization’s identity provider, over OIDC or SAML 2.0 |
opentremor_scim_config | An organization’s SCIM 2.0 provisioning, including token rotation |
opentremor_team / opentremor_team_member | Teams and their membership |
opentremor_rule_category / opentremor_rule | Custom security rules and their grouping; a rule’s optional scope limits it to teams, repositories or products |
opentremor_product | Products: groups of repositories whose teams review every one of them |
opentremor_repository / opentremor_repository_rule_exclusion | A listed repository’s teams, product, packs, rule variants, LLM and ADR sources, and the custom rules turned off for it |
opentremor_repository_ownership | The organization’s ownership rules and default review team |
opentremor_jira_integration | The organization’s Jira site, default target, rules, priorities and transitions (Jira) |
opentremor_jira_product_target / opentremor_jira_team_target | Where a product’s or a team’s new Jira issues go |
opentremor_report_template | Organization-owned Jinja2 report templates |
opentremor_address_list | Named IP or host lists: entered manually, fetched from a URL, or read from a file on the server |
opentremor_network_rule | Which IP lists can reach a path prefix on the API, dashboard, or docs (Network Access) |
opentremor_audit_sink / opentremor_platform_audit_sink | Where an organization’s audit events, or every event on the instance, are streamed over HTTPS or syslog (Audit Log Streaming) |
Data sources:
| Data source | Reads |
|---|---|
opentremor_address_list | An address list by name, with its current entries (resolved) |
opentremor_saml_service_provider | The SAML entity id and ACS URL to enter in an organization’s IdP, before the connection exists |
Credentials
Section titled “Credentials”The provider supports two of the five credential shapes described in Authentication — Access scope at a glance:
provider "opentremor" { base_url = "https://api.example.com"
# Organization-scoped resources. api_key = var.opentremor_api_key
# Platform-admin resources, and organization creation. admin_email = var.opentremor_admin_email admin_password = var.opentremor_admin_password}Set at least one credential. The resources you use determine which one you need:
- Organization-scoped resources (
/orgs/{org_id}/*,/auth/keys) work with either credential. The API key is preferred when both are set because it is already bound to the right organization and needs no login round-trip. - Platform-admin resources (
/admin/*) requireadmin_email/admin_password. OpenTremor never grantsis_superadminto a stored API key, so no key can reach these resources. This includes the bootstrap key, which is auto-superadmin but has nouser_id. - Creating an organization (
POST /v1/orgs) requires a session. The endpoint checks for a realuser_id, not the superadmin flag.
One provider block, one organization
Section titled “One provider block, one organization”Both credential types are single-organization, so each organization-scoped resource’s org_id defaults to
the organization associated with the provider’s credential. The provider resolves it once per run via
GET /v1/auth/me. You do not need to configure it in the common case.
Setting org_id to a different organization is rejected before the request goes out. The API’s
require_same_org check responds to every cross-organization request on /orgs/{org_id}/* with a 404
rather than a 403. This prevents one organization from confirming that another organization’s resources exist.
The provider gives the same refusal with an explanation.
To manage several organizations, use one provider alias per organization:
provider "opentremor" { alias = "acme" base_url = "https://api.example.com" api_key = var.acme_api_key}
resource "opentremor_team" "acme_platform" { provider = opentremor.acme name = "Platform"}A single block cannot span organizations because re-scoping a session
(POST /v1/auth/session/switch) mutates one shared cookie while Terraform applies resources
concurrently. A switch for one resource would silently retarget every in-flight request
for another.
Worked example
Section titled “Worked example”# Platform-wide, requires the admin session.resource "opentremor_platform_settings" "this" { overrides = jsonencode({ logging_level = "INFO" registration_allow_public_signup = false retention_audit_days = 730 })}
# Organization-scoped, works with the API key.resource "opentremor_organization_settings" "this" { monthly_budget_usd = 500 report_link_ttl_hours = 72 allowed_sign_in_methods = ["password", "sso"] agent_access = "read_only"
injection_semantic_scoring = true injection_gate = "fail"
code_suggestions = true code_suggestions_min_severity = "HIGH" code_suggestions_max_per_review = 10
support_assistant = true support_assistant_connection_id = "anthropic" support_assistant_model = "claude-haiku-5-5"}
resource "opentremor_sso_connection" "entra" { display_name = "Acme Corp" issuer = "https://login.microsoftonline.com/${var.tenant_id}/v2.0" client_id = var.client_id client_secret = var.client_secret default_role = "member" allowed_domains = ["acme.com"]}
# Or SAML 2.0, from the IdP's metadata. The IdP needs# data.opentremor_saml_service_provider's entity_id and acs_url first.# resource "opentremor_sso_connection" "adfs" {# protocol = "saml"# display_name = "Acme ADFS"# idp_metadata_xml = file("adfs-metadata.xml")# }
resource "opentremor_rule_category" "storage" { name = "Storage & data"}
resource "opentremor_rule" "no_public_buckets" { title = "No publicly readable object storage" description = "Flag any bucket whose ACL or policy would let an unauthenticated principal read objects." category = opentremor_rule_category.storage.id severity = "HIGH" packs = ["terraform-plan"]}
resource "opentremor_product" "checkout" { name = "Checkout" team_ids = [opentremor_team.acme_platform.id]
# Every pack starts off. These run on each of the product's repositories. enabled_packs = ["terraform-plan"]}
# Runs only on pull requests of the Checkout product's repositories.resource "opentremor_rule" "card_data_encrypted" { title = "Card data stays encrypted" description = "Flag any storage of card numbers without encryption at rest." category = opentremor_rule_category.storage.id severity = "HIGH" packs = ["terraform-plan"]
scope = { product_ids = [opentremor_product.checkout.id] }}A rule without scope runs on every analysis of the organization. With scope, it runs only on pull requests whose repository is owned by one of the listed teams, is listed under repositories, or belongs to one of the listed products. API analyses that name no repository never run it.
Repositories
Section titled “Repositories”A repository is never created by Terraform. OpenTremor lists it when GitHub or GitLab is connected. opentremor_repository manages the settings of a listed repository, keyed by code_host and external_id: its teams, product, disabled packs, rule variants, LLM, the ADRs its rules are drawn from (knowledge_sources, see Rules from ADRs), and whether draft pull requests are reviewed (review_drafts; unset or false means a draft is reviewed once marked ready). Run Sync now first if the repository is not listed yet; the apply fails otherwise. Destroying the resource clears these settings and leaves the repository listed.
resource "opentremor_repository" "payments_api" { code_host = "github" external_id = "123456789" team_ids = [opentremor_team.acme_platform.id] product_id = opentremor_product.checkout.id enabled_packs = ["python-code-change"] rule_variants = { "terraform-plan" = "aws" } review_drafts = true
code_suggestions = false # whatever the organization setting
llm = { connection_id = "conn_eu" model = "claude-sonnet-5-5" }
# Read docs/adr on the default branch; proposed rules apply to the whole product. knowledge_sources = [ { kind = "adr", paths = ["docs/adr"], applies_to = "product" }, ]}
# Turns one custom rule off for this repository, whatever its scope.resource "opentremor_repository_rule_exclusion" "no_pci" { code_host = "github" external_id = "123456789" rule_id = opentremor_rule.card_data_encrypted.id reason = "Holds no card data"}
# One per organization: the rules fill what a newly discovered repository has not set.resource "opentremor_repository_ownership" "this" { rules = [ { pattern = "acme/payments-*" team_ids = [opentremor_team.acme_platform.id] product_id = opentremor_product.checkout.id rule_variants = { "terraform-plan" = "aws" } }, { # Every other repository reads its ADRs from the usual folders. pattern = "*" knowledge_sources = [{ kind = "adr" }] }, ] default_review_team_id = opentremor_team.acme_platform.id}Ownership rules never overwrite a setting made on a repository. If both manage the same repository, opentremor_repository wins. Import IDs: github/123456789 for a repository, github/123456789/<rule_id> for an exclusion, the organization ID for the ownership rules.
Platform settings are JSON, not typed attributes
Section titled “Platform settings are JSON, not typed attributes”opentremor_platform_settings.overrides takes a JSON object of flat {section}_{field} keys,
not a fixed set of Terraform attributes. This is deliberate. The settings field vocabulary is built
at runtime from a registry, and every installed domain contributes its own sections
(see Data Retention for a section added this way). A fixed provider
schema would silently reject fields added on the server after the provider binary was built.
The resource’s effective attribute reports every editable field with its value as actually in
force. It is the authoritative list for a given instance:
terraform state show opentremor_platform_settings.thisSettings excluded from this surface — storage, cors, auth, jwt, two_factor,
secrets, telemetry, deployment — remain file- or environment-driven and cannot be set here. GET /v1/admin/settings
reports each exclusion and its reason.
Behaviour worth knowing before you rely on it
Section titled “Behaviour worth knowing before you rely on it”Some behaviors follow from what the API does or does not offer, rather than from a provider choice:
- Organizations cannot be renamed or deleted. There is no endpoint for either action. Changing
namecreates a new organization.terraform destroyremoves the resource from state and warns that the organization remains on the server. - API keys are replace-only and cannot be imported. The raw key exists only in the create response,
and stored keys are not editable. Any change to
name,roleorip_allowlistissues a new key and revokes the old one. Hand out the replacement before applying. - Secrets cannot be read back. An SSO
client_secretis stored encrypted, a SAMLidp_metadata_xmlis not kept as a document, and a SCIMtokenis stored as a hash, so Terraform cannot detect drift for either. An imported SSO connection shows aclient_secretoridp_metadata_xmlchange on its first plan because Terraform does not know the current value. An imported SCIM config has no token until it is rotated. - SCIM provisioning and
opentremor_teamoverlap. Each SCIM group maps one-to-one to a team, so an identity provider with provisioning enabled creates and deletes teams and memberships. Managing the same teams from Terraform gives two writers access to the same rows. - Enabling any custom rule for a pack replaces that pack’s built-in ruleset for that pack+variant. OpenTremor stops rendering the built-in bullets entirely. Manage the whole set for those packs rather than adding a single rule.
- A network rule that would block the address Terraform runs from is refused. The API checks
every rule change against the caller’s own address. Allow that address first, or create the rule in
reportmode (the default) and switch toenforcelater. - An address list in use cannot be destroyed. The API refuses while a rule or an egress policy
names it. Terraform orders this correctly when the rule references the list’s
nameattribute. - Jira needs the platform switch first. Set
jira_enabled = trueinopentremor_platform_settingsbeforeopentremor_jira_integration, with adepends_on. Theapi_tokenis never returned, so a rotation done elsewhere is invisible, and an imported integration shows a token change on its first plan. opentremor_pricingcannot be destroyed back to the defaults. There is no endpoint to clear a stored price list, and the API reports built-in defaults and an identical custom list the same way. Destroy warns and leaves the tiers in force.
Not covered yet
Section titled “Not covered yet”The provider does not manage LLM models and credentials or per-organization pack enablement. These product-side configuration areas are outside the resources listed above.