{"token_count": 1930}

# Configure the Okta Integration using Terraform

Identity Governance is available only with Teleport Enterprise.

In this guide, you will use Terraform to configure the Okta side of the Teleport Okta integration, and then finish enrolling the integration with the guided flow in the Teleport Web UI.

If you are new to the Teleport Okta integration, start by reading [how the integration works](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta.md#how-it-works).

## How it works

The `okta-integration` Terraform module creates the following Okta resources:

- A SAML 2.0 app that Teleport uses for SSO, with the Okta groups you choose assigned to it. This replaces the Okta steps of the [Guided Okta SSO Integration](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/guided-sso.md).
- An API Services app that Teleport uses to call the Okta API for [user sync](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/user-sync.md) and [application and group sync](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/app-and-group-sync.md). Teleport authenticates to Okta with a JWT signed by its Okta key, and Okta fetches the public key from the `/.well-known/jwks-okta` endpoint of the Teleport Proxy Service.
- A custom admin role and a resource set that limit which Okta users, groups, and apps Teleport can access, assigned to the API Services app.

---

SCIM PROVISIONING

The Terraform module doesn't configure SCIM provisioning. Okta doesn't allow enabling provisioning on a custom SAML app through its API, so you must enable it in the Okta Admin Console. Follow the [Okta SCIM Integration](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/scim-integration.md) guide after you complete this guide.

---

## Prerequisites

- Teleport Identity Governance enabled for your Teleport cluster.
- An Okta organization with a super administrator account. Creating a custom admin role, a resource set, and an admin role assignment for an app requires super administrator permissions.
- Terraform installed on your workstation.
- The Teleport Proxy Service must be reachable from Okta, so Okta can fetch the Teleport JWKS. See [Private Teleport clusters](#private-teleport-clusters) if it isn't.

## Step 1/3. Prepare Terraform

Clone the Teleport Okta integration example module, which is available in the Teleport GitHub [repository](https://github.com/gravitational/teleport/tree/master/examples/terraform/okta-integration). The module is based on the `okta` [provider](https://registry.terraform.io/providers/okta/okta/latest/docs). The provider reads Okta credentials from your environment, for example:

```
$ export OKTA_API_TOKEN=...
```

## Step 2/3. Configure and apply

The module expects at least the following input variables:

- `okta_org_name`: Okta organization name, e.g., `dev-123456` for `dev-123456.okta.com`.
- `okta_base_url`: Okta organization domain, e.g., `okta.com` or `oktapreview.com`. Defaults to `okta.com`.
- `proxy_service_address`: Teleport Proxy Service host, e.g., `example.teleport.sh`.
- `group_names`: Okta groups whose members can log in to Teleport. Only users assigned to the SAML app, directly or through these groups, are synced to Teleport.

You can see other accepted variables in the module's [variables.tf](https://github.com/gravitational/teleport/blob/master/examples/terraform/okta-integration/variables.tf). Create a `tfvars` file with your inputs:

```
$ cat > variables.auto.tfvars << EOF
okta_org_name         = "..."
okta_base_url         = "..."
proxy_service_address = "..."
group_names           = ["..."]
EOF
```

Then apply the configuration:

```
$ terraform init
$ terraform plan
$ terraform apply
```

Once the changes are applied, the module produces the following outputs, which you will need in the next step:

- `saml_metadata_url`: Metadata URL of the Okta SAML app.
- `okta_org_url`: URL of your Okta organization.
- `api_app_client_id`: Client ID of the Okta API Services app.

To print them again later, run `terraform output`.

---

BIDIRECTIONAL OKTA SYNC

By default, Okta integration is one-way and syncs Okta groups as read-only Access Lists. When enabling bidirectional sync on Teleport integration to let Teleport make changes in Okta (for example to request access to Okta apps with Access Requests), flip the `enable_bidirectional_sync` flag to `true` in your terraform config and re-apply.

---

## Step 3/3. Enroll the integration in Teleport

---

TELEPORT IAC

Teleport Okta integration can't currently be installed via infrastructure-as-code but you can configure the [SAML connector](https://goteleport.com/docs/ver/20.x/reference/infrastructure-as-code/teleport-resources/saml-connector-v2.md) with Terraform.

---

Finish the integration in the guided flow, using the module outputs instead of creating apps in the Okta Admin Console:

1. In the Teleport Web UI, navigate to **Add New** -> **Integration** and select the **Okta** tile.
2. Follow the SSO setup flow to create a new connector. Use `saml_metadata_url` from Terraform output. The SAML is created by terraform, so skip the Okta app configuration steps described in the [Guided Okta SSO Integration](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/guided-sso.md).
3. When setting up User Sync, use `api_app_client_id` from Terraform output. The module creates the API Services app and configures it to trust the Teleport JWKS URL, so skip Steps 1 and 2 of the [User Sync](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/user-sync.md) guide.
4. In the app and group sync, set default Access List owners and, optionally, filters. See [Application and Group Sync](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/app-and-group-sync.md).
5. Optionally enable SCIM provisioning by following the [Okta SCIM Integration](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/scim-integration.md) guide. The Terraform module doesn't configure SCIM, so you must set it up in the Okta Admin Console.

## Private Teleport clusters

If Okta can't reach the Teleport Proxy Service, replace `jwks_uri` in the `okta_app_oauth.teleport_okta_integration_api` resource with a [jwks](https://registry.terraform.io/providers/okta/okta/latest/docs/resources/app_oauth#jwks-1) block that holds the public key shown under **If your cluster is private** in the user sync step of the guided flow, and apply the configuration again.

```
resource "okta_app_oauth" "teleport_okta_integration_api" {

  # Remove jwks_uri and add one jwks block for each key in the key set.
  jwks {
    kty = "EC"
    kid = "..."
    x   = "..."
    y   = "..."
  }

}

```

## Next steps

- Configure [SCIM provisioning](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/scim-integration.md).
- Review the [Okta integration reference](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta/reference.md).
- Learn how to [manage integration components](https://goteleport.com/docs/ver/20.x/identity-governance/integrations/okta.md#managing-integration-components).
