Terraform Provider
Terraform is an infrastructure-as-code tool that lets you define your environment configuration in .tf files and apply it consistently across development, staging, and production. Instead of configuring environments by hand, you declare a desired state and let Terraform manage it. Read more at developer.hashicorp.com/terraform/intro.
Descope publishes a Terraform provider for managing projects and their configuration.
Important
Terraform is best suited for managing infrastructure and configuration that should be consistent across environments. Dynamic elements of a project—such as individual users, tenants, SSO connections, and SCIM configurations—are not typically managed by Terraform. These are unique to each project or environment and are generally handled through the Descope Console, SDKs, or APIs, and not as infrastructure-as-code.
Prerequisites
Note
The Terraform provider works with a paid Descope license (Pro +). For licensing questions, contact support@descope.com.
- Terraform CLI 1.0 or later installed.
- A Management Key from Company Settings. Set the scope to All Projects if you intend to create new projects via Terraform.
Using the Terraform Provider
Provider Configuration
Declare the Descope provider in your .tf file:
Warning
Never hardcode your management key in Terraform configuration files—this risks exposing it in version control. Use environment variables or a secrets manager instead.
| Variable | Description |
|---|---|
DESCOPE_MANAGEMENT_KEY | A valid management key for your Descope company |
DESCOPE_BASE_URL | Override the Descope API base URL (optional, for testing) |
With those set, the provider block needs no additional configuration:
Run terraform init to download the provider:
If you need to configure credentials explicitly (e.g. in a module):
Creating a Project
Add a project resource to your .tf file:
Attributes like tags support dynamically computed values:
Examples
Each example below is an attribute inside the descope_project resource.
Project Settings
Configure project-level settings:
Full project settings schema reference
Invite Settings
Configure user invitation behavior:
The expire_invited_users flag causes invited user accounts to expire if the invitation is not accepted within the invite_expiration duration. The invite_expiration field accepts human-readable durations such as "2 weeks" or "4 days", with a minimum value of "1 hour". Use it alongside expire_invited_users and/or add_magiclink_token.
Full invite settings schema reference
Authorization
Configure permissions and roles:
Full authorization schema reference
Authentication
Configure authentication methods:
Full authentication schema reference
Attributes
Configure custom attributes for users and tenants:
Full attributes schema reference
Connectors
Connectors support bearer token auth and role-based auth:
Full connectors schema reference
JWT Templates
Use jwt_templates to configure custom JWT claim templates. You can include a description, control which standard claims are included, and add security features like JTI:
Full JWT templates schema reference
SSO Settings
Configure global settings for Single Sign-On across all tenants in your project:
Note
When using email_service, the connector must be set to an existing HTTP connector defined in your connectors block. If any template has active = true, the connector cannot be "Descope" (the built-in default). Each template requires either html_body (default) or plain_text_body with use_plain_text_body = true. Template names must be unique and cannot be "System".
Full SSO settings schema reference
Flows and Styles
If you've designed custom flows in the Descope console, you can export and load them via Terraform:
- In the Descope console, go to Authentication Flows
- Open the flow you want to manage, click the export button, and save the JSON file (e.g.,
flows/sign-up-or-in.json) - Optionally export your flow styles from the same screen and save as
flows/styles.json - Reference the files in your configuration:
Full flows schema reference · Full styles schema reference
Full Terraform Plan Example
Additional Resources
Users and tenants are generally not managed via Terraform, but some dynamic resources have dedicated resource types. Defining them as code keeps access control auditable and consistent across environments.
Management Keys
Use descope_management_key to manage Descope Management Keys as code, alongside the rest of your project configuration.
Important
The raw key value (cleartext) is only available immediately after creation and cannot be retrieved later. Store it in a secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault) right after terraform apply.
Keys can be scoped to restrict access at the company level, per project, or by project tag:
Full management key schema reference
Descopers (Console Users)
Use descope_descoper to manage Descopers as code. Roles can be scoped to the entire company, to specific projects, or to all projects with a given tag.
Available roles: admin, developer, support, auditor.
Full descoper schema reference
Applications
Like users and tenants, applications are dynamic resources that vary per environment. The Terraform provider supports two types: Federated Apps (First Party Applications, configured inside descope_project) and Inbound Apps (Third Party Applications with Scopes and Consent, managed as a standalone descope_inbound_app resource).
Federated Apps
Use the applications block inside descope_project to configure OIDC and SAML applications for outbound SSO integrations.
Full applications schema reference
Inbound Apps
Use descope_inbound_app to manage third-party applications that authenticate users via Descope as an OAuth 2.0 identity provider. OAuth clients, MCP server configurations, and partner integrations all benefit from being version-controlled alongside your project.
Scopes (permissions_scopes, attributes_scopes, connections_scopes) each take the same shape:
| Field | Required | Description |
|---|---|---|
name | Yes | Unique identifier for the scope |
description | Yes | Description shown during the consent flow |
values | No | Identifiers of the underlying permissions, attributes, or connections this scope grants |
optional | No | When true, the user may decline to grant this scope during authorization |
Full inbound app schema reference
Using Terraform Within Your Environment
Terraform tracks your Descope project in a state file. Store it somewhere your team can access — remote backends like S3 or Terraform Cloud work well.
- Run
terraform planto preview changes before applying. - Run
terraform applyto apply them.
