Back up and restore an Okta tenant with Terraform
You already manage Okta with Terraform. Can you use it as a backup and restore tool? The short answer is no.
What Terraform really can and cannot do with Okta.
Technical article. Sources: Okta Developer documentation, HashiCorp Terraform, the okta registry (v7.1.0), the Okta DevForum, and a fair amount of hands-on Terraform and Okta experience.
The starting point
A lot of teams ask the same question: "We already manage Okta with Terraform. Can we use it as a backup and restore tool?" The short, documented answer below is no. Even so, Terraform can do quite a lot, and that can usefully contribute to a partial backup and restore of your Okta tenant. Let's look at it more closely.
Terraform describes a desired configuration, compares it with what already exists, then pushes changes through the API. It is not a tool designed to back up an Okta tenant. HashiCorp puts it this way: state links your resources to remote objects. It is not a backup. Okta presents Terraform as a lever for audit, control, and deployment. And in the field, the experience is unambiguous: Terraform is excellent, but it is not a backup and restore tool.
The Okta DevForum points the same way: a full transfer of a tenant's configuration is not available to customers.
What you can actually do with Terraform: version the configuration the provider knows how to manage, import it if it already existed outside Terraform, and reapply it to the same org or to another Okta org. This is not a point-in-time snapshot of the tenant (users, MFA enrollments, secrets, system apps, directory sync, history, and so on are not included).
What Terraform actually "saves"
The .tf files in Git are the real memory of the configuration, but only for what has been coded or imported. The terraform.tfstate file is only an operational mapping (config ↔ Okta IDs). Okta recommends storing it remotely (S3, HCP Terraform, and so on) so you can version it, encrypt it, and share it. Useful, even essential on a team… but it does not replace a real Okta backup.
There are also two Okta recommendations that will save you a lot of grief: one Terraform configuration per org, and a single management mode per object type (either Terraform or the Admin Console). Mixing the two is a near guarantee of drift.
How to capture the configuration (the realistic "backup")
Starting from scratch
The ideal scenario: you declare groups, apps, policies, and authorization servers in HCL, you version them, you apply, and you put state in a remote backend. In that world, the "backup" of the managed configuration is Git plus the remote backend.
When the Okta org already exists
Then you go through import. Since Terraform 1.5, import blocks replace the old hand-run terraform import. Okta documents two approaches.
The first, minimal one: you create the resource, you add the import with the Okta ID (taken from the Admin Console URL or from the LIST API), you run terraform plan, and you align every field that drifts from the provider defaults. You repeat until the diff is zero, then apply. Okta is emphatic about this: skip the alignment and you risk surprise changes on the org.
The second is more comfortable for an audit: terraform plan -generate-config-out=…. Terraform generates the HCL, you trim useless defaults, you replace raw IDs with references (okta_policy.xxx.id), you copy the result into the main configuration, you re-plan until it is stable, then apply.
Two Okta guardrails to keep in mind: it is better not to import users (too large: memberships plus app assignments), and Okta feature settings cannot be imported. For singleton objects (some settings), the dummy singleton ID, "." or "_", does the job.
How to "restore"
Same tenant
The goal is to have Terraform adopt existing objects without recreating them. Keep the import blocks with the current tenant's IDs. The plan must say "will be imported," not "will be created." Without an import, an empty state will try duplicate CREATEs. That is a classic, and it hurts.
Another tenant (staging to production, or a fallback org)
Point the provider at the target, remove the import blocks (the source IDs do not exist there), and make sure cross-references are Terraform expressions, not literal IDs. Okta IDs do not travel from one org to another. Secrets (client secrets, keys, integration passwords) are supplied separately: they generally do not come out in the HCL. Then plan, review, and apply. You rebuild what the provider knows how to create, not the entire tenant.
The limits you have to accept
The provider does not cover the whole Okta model. System apps, some built-ins, feature settings that cannot be imported, schemas or policy conditions that are sometimes poorly mapped: there are gaps in quite a few places.
Dynamic data — users, directory-backed objects, highly volatile integrations — does not fit well in a durable Terraform model. Okta confirms this by advising against importing users.
No point-in-time snapshot, no tenant rollback, no magical dependency clone:
Drift between the Admin Console UI and Terraform is real. So are rate limits: a large plan or apply can fail with HTTP 429. Okta documents this: max_api_capacity, backoff, saved plans, refresh=false (with precautions).
And even after a successful apply on a new org, passwords, MFA factors already enrolled, sessions, logs, live AD/LDAP sync, and configuration outside the provider… none of that "comes back" through Terraform.
Pros and cons, on one page
| Topic | The upside | The downside |
|---|---|---|
| Positioning | Very good for Okta IaC: review, CI/CD, reproducible configuration | It is not a tenant backup or disaster-recovery tool |
| Backup | Versioned .tf files save the declared configuration | No full capture and no PITR |
| Restore, same org | Import plus apply: a clean adoption | Import takes a long time; risk if fields are not aligned |
| Restore, another org | Recreation is possible if the code is clean | IDs are not portable; secrets must be reinjected; provider gaps |
| Users and directories | Groups and assignments are a better fit | Users are not recommended; directories are too dynamic |
| State | Remote backend: versioning, locking, collaboration | State is not a backup; it can contain secrets |
| Operations | A readable plan and a controlled apply | Rate limits, expensive refreshes, large graphs that are slow |
| Governance | One management mode per object type | UI plus Terraform means drift and perpetual diffs |
| Real disaster recovery | Speeds up configuration rebuilds | No PITR, no native standby tenant |
Object-by-object matrix: Okta object → Terraform resource → can it be backed up?
"Can be backed up" here means: configuration that can be represented and reapplied through Terraform, not a full backup of the Okta tenant.
Conventions and definitions:
| Value | Meaning |
|---|---|
| Yes (config) | Can be represented in HCL and reapplied (same org via import, another org via recreate) |
| Partial | The resource exists, but the restore is incomplete (secrets, runtime, gaps, manual steps) |
| Not recommended | Technically possible, a poor choice for a backup or disaster-recovery strategy |
| No | No useful resource, not importable, or a system object outside the provider |
Applications and assignments
| Okta object | Terraform resource | Can be backed up |
|---|---|---|
| OIDC / OAuth app | okta_app_oauth (+ redirect URI, API scope, role assignment…) | Partial (secrets must be reinjected) |
| SAML app | okta_app_saml (+ app_settings) | Partial (certs / metadata) |
| Bookmark / SWA / Auto Login / Basic Auth / SPS / Three Field / Shared Creds | okta_app_bookmark, okta_app_swa, okta_app_auto_login, okta_app_basic_auth, okta_app_secure_password_store, okta_app_three_field, okta_app_shared_credentials | Yes (config) / Partial if credentials are involved |
| App access policy assignment | okta_app_access_policy_assignment | Yes (config) |
| App sign-on policy / rules | okta_app_signon_policy, okta_app_signon_policy_rule(s) | Yes (config) |
| Group → app assignment | okta_app_group_assignment(s) | Yes (config) |
| User → app assignment | okta_app_user | Not recommended |
| App profile schema | okta_app_user_schema_property, okta_app_user_base_schema_property | Yes (config) |
| System apps (Admin Console…) | — | No |
| App features / tokens | okta_app_features, okta_app_token | Partial |
Users, groups, schemas
| Okta object | Terraform resource | Can be backed up |
|---|---|---|
| User | okta_user | Not recommended (Okta); passwords and MFA are not restored |
| User admin roles | okta_user_admin_roles | Partial |
| Memberships | okta_user_group_memberships, okta_group_memberships | Partial / not recommended at scale |
| User factor (question) | okta_user_factor_question | No |
| Group | okta_group | Yes (config) |
| Group rule / owners / roles | okta_group_rule, okta_group_owner(s), okta_group_role | Yes (config) |
| Group / user schemas | okta_group_schema_property, okta_user_schema_property, okta_user_base_schema_property | Yes (config) |
| User type / profile mapping | okta_user_type, okta_profile_mapping | Yes (config) |
| Built-in group (Everyone…) | data source, not a classic export | No (reference it, do not "back it up") |
Policies and authentication
| Okta object | Terraform resource | Can be backed up |
|---|---|---|
| Sign-on / global session | okta_policy_signon + okta_policy_rule_signon | Yes (config) |
| MFA policy | okta_policy_mfa / _default + okta_policy_rule_mfa | Yes (config) |
| Password policy | okta_policy_password / _default + okta_policy_rule_password | Yes (config) |
| Profile enrollment | okta_policy_profile_enrollment (+ rules/apps) | Yes (config) |
| IdP discovery | okta_policy_rule_idp_discovery | Yes (config) |
| Device assurance | okta_policy_device_assurance_* | Yes (config) |
| Org authenticators / factors | okta_authenticator*, okta_factor, okta_factor_totp | Yes (config) |
| MFA enrollment already completed by a user | — | No |
Authorization servers
| Okta object | Terraform resource | Can be backed up |
|---|---|---|
| Authorization server | okta_auth_server, okta_auth_server_default | Yes (config) |
| Claims / scopes / policies / rules | okta_auth_server_claim(_default), _scope, _policy, _policy_rule | Yes (config) |
IdP, network, branding, hooks, org
| Okta object | Terraform resource | Can be backed up |
|---|---|---|
| SAML / OIDC / social IdP | okta_idp_saml, okta_idp_oidc, okta_idp_social (+ okta_idp_saml_key) | Partial (keys/secrets) |
| Network zones / trusted origins / behavior / ThreatInsight | okta_network_zone, okta_trusted_origin, okta_behavior, okta_threat_insight_settings | Yes (config) |
| Brand / theme / sign-in pages | okta_brand, okta_theme, okta_customized_signin_page… | Partial (the brand↔email_domain link is sometimes outside Terraform) |
| Custom domain + certificate | okta_domain, okta_domain_certificate, okta_domain_verification | Partial (certs / DNS) |
| Email domain / sender / templates / SMS | okta_email_*, okta_template_sms | Partial / yes, depending on the object |
| Event / inline hooks | okta_event_hook, okta_inline_hook | Partial |
| API token / org settings / rate limits / captcha | okta_api_token, okta_org_configuration, okta_rate_limiting… | Partial |
| Feature flags | okta_feature | Partial; importing feature settings: no |
| Custom admin roles / resource sets / realms / log streams | okta_admin_role_custom, okta_resource_set, okta_realm*, okta_log_stream… | Yes (config) / partial |
Clearly outside Terraform
| Okta object | Can be backed up with Terraform |
|---|---|
| User passwords | No |
| User MFA enrollments / devices | No |
| Active sessions | No |
| System Log / history | No |
| Live AD/LDAP sync state | No |
| Okta Workflows (full business logic) | No |
| Configuration on third-party service providers | No |
| Full tenant transfer | No |
So if the answer remains "Terraform is not designed for backup and restore," you can still do useful things as part of an Okta backup policy. Your backup strategy simply cannot stop at Terraform (too many Okta objects are missing), and Terraform use in the organization has to be fully under control, to avoid the well-known drift and deviation effects with Okta.
Where to start if you want to use Terraform for disaster recovery
If you really want to use Terraform for backup, only the following objects are genuinely worth it: groups and group rules, authorization servers, policies and rules, OIDC/SAML apps (with secrets handled separately), group assignments, network zones, trusted origins, and schemas.
Useful but more fragile: branding, domains, emails, IdPs, hooks, tokens, and org settings.
Leave these out of a Terraform backup strategy: users, large-scale memberships, user factors, and system apps.
Conclusion
Terraform versions and redeploys the Okta configuration that the provider knows how to manage. That is useful, and it is incomplete. It cannot be your only Okta disaster-recovery solution.
"Git + remote state" protects the Terraform code and state. For a real tenant restore, point-in-time recovery, or a complete dependency graph, you need to consider a dedicated component, or to complement Terraform with specific scripts. Okta does not provide a native tenant transfer, and Terraform does not fully fill that gap.