Terraform’s Okta provider treats your Okta identity configuration like any other infrastructure, allowing you to version, test, and deploy changes to users, groups, applications, and policies using code.

Let’s see it in action. Imagine you need to provision a new Okta application and assign a group of users to it.

provider "okta" {
  org_name = "your-company.okta.com"
  token    = var.okta_api_token
}

variable "okta_api_token" {
  description = "Okta API token for Terraform"
  type        = string
  sensitive   = true
}

resource "okta_app_oauth" "my_app" {
  label                      = "My Terraform App"
  grant_types                = ["authorization_code"]
  redirect_uris              = ["https://myapp.example.com/callback"]
  response_types             = ["code"]
  client_id                  = "abcdef123456"
  client_secret              = "supersecretkey"
  token_endpoint_auth_method = "client_secret_post"
}

data "okta_group" "developers" {
  name = "Developers"
}

resource "okta_app_user_assignment" "developer_assignment" {
  app_id = okta_app_oauth.my_app.id
  user_id = data.okta_group.developers.id # Note: This assigns the *group* to the app, not individual users directly. Okta handles group membership.
}

This Terraform configuration defines an OAuth application (okta_app_oauth) with specific grant types and redirect URIs. It then references an existing Okta group named "Developers" using a data source. Finally, it creates an okta_app_user_assignment resource to link the "My Terraform App" to the "Developers" group. When you run terraform apply, Terraform will communicate with the Okta API to create these resources if they don’t exist, or update them if they do, ensuring your Okta configuration matches your code.

The core problem the Okta Terraform provider solves is the manual, error-prone, and often undocumented process of managing identity infrastructure. Instead of clicking through the Okta admin console, you define your users, groups, applications, authentication policies, and even role assignments in declarative configuration files. This enables version control, peer review, automated testing, and repeatable deployments, bringing the benefits of Infrastructure as Code to your identity management. Internally, the provider translates these declarative resources into API calls to Okta’s various endpoints. For instance, okta_app_oauth maps to Okta’s application management APIs, while okta_user would map to user management APIs.

When you define an okta_group resource, you can specify its profile details, including custom attributes, which can then be used in application assignments or policy conditions. This allows for granular control over how users are provisioned and what access they receive based on their group memberships and attributes.

A common point of confusion is how to manage individual user assignments versus group assignments. While you can assign individual users to applications using okta_app_user_assignment by providing a user_id, it’s often more scalable and manageable to assign entire groups to applications. The Okta API and Terraform provider support this by allowing you to reference a group’s ID in the user_id field of an okta_app_user_assignment resource. Okta then handles the enforcement of this assignment based on who is a member of that group, effectively granting or revoking access to the application for all members. This leverages Okta’s built-in group membership management for efficient access control.

The next hurdle most people encounter is managing Okta’s sophisticated network and threat protection policies using Terraform.

Want structured learning?

Take the full Okta course →