TL;DR: Terraform rebuilds the Okta configuration in your repo. It doesn't bring back the memberships, app assignments and deleted objects that live outside it. After a bad apply or an attack, what's missing decides how long people stay locked out.
If you manage Okta with Terraform, you've probably had this thought: everything's in git, so if something breaks, I'll revert and reapply.
It's a reasonable assumption, since your policies, apps and groups are all in code, every change gets reviewed, and you can rebuild a preview org from the repo whenever you need one.
The trouble is that a working Okta tenant is more than its configuration. It's also who's in each group and which apps and policies apply to them. Most of that was never in your repo, so a reapply can't bring it back. In its disaster recovery documentation, Okta describes its job as keeping the service available and leaves recovering from deleted data or configuration mistakes to the customer.
A reapply restores the Okta configuration your repo describes. The group memberships, app assignments, and deleted objects that live outside it come back only when someone rebuilds them by hand, and that rebuilding sets how long people stay locked out. One routine refactor that deletes and recreates a single group is enough to expose the gap. Solutions like Rubrik Security Cloud can close this gap by keeping point-in-time copies of the live Okta tenant outside both the tenant and your pipeline, then relinking memberships and assignments when it recreates an object.
What Terraform Does Well for Okta
For managing Okta configuration, Terraform is the right tool. Code review and terraform plan catch mistakes before production, and git gives you a history of every policy anyone has touched. When someone edits a managed resource in the Admin Console, the next plan shows you the drift.
Okta's own Terraform guides describe it as a way to control change. However, recovery is a different job, and the difference shows up as soon as an apply goes wrong.
How One Refactor Breaks Access
Say someone on your team tidies up a module and renames the resource for your Finance group, but forgets the moved block that tells Terraform it's still the same object. Terraform reads the rename as one group going away and another arriving, so the next apply deletes the original group and creates a new one that matches the code exactly. A careful reviewer might catch the replacement in the plan, but in a routine cleanup it's one line among dozens and easy to approve.
In code, the new group matches your settings perfectly. But Okta has assigned it a completely different ID. While internal references update naturally, every app assignment, policy rule, or external workflow targeting the former identifier breaks.
Within minutes, people start losing access because the new group only has the members your code lists. Most teams that manage every group in code still leave membership to other tools. Group rules, joiner-mover-leaver automation in Okta Workflows, and approved access requests all add people to groups on their own schedule. Rule-driven members trickle back as the rule re-evaluates, which can take hours on a large tenant. People added by automation or access requests don't come back at all because Terraform only knew about the members you listed. The same goes for any app assignment or policy rule that pointed at the old group from outside Terraform.
Memberships you do manage directly can still slip through. By default, okta_group_memberships only tracks the users you list in it, so anyone added by a rule, an import or a colleague in the Admin Console never appears in your plan. Setting track_all_users changes this, so check whether your modules use it.
What a Terraform Restore Actually Involves
Back to the refactor. The access tickets start coming in and the obvious fix is to roll back and reapply. In practice, that turns into a series of judgment calls made under pressure. Rolling back the rename doesn't even bring the original group back. Terraform destroys the replacement and creates a third group with a third ID.
The first challenge is deciding where to anchor the rollback. Reverting to the commit preceding your refactor leaves every subsequent update out of git while it remains present in state, prompting the upcoming plan to teardown those additions as well. Before you can safely run another apply, someone must sort through subsequent updates, deciding which edits to preserve while manually piecing your configuration back together.
The plan itself is the next problem. Accumulated changes made in the Admin Console surface during the plan as configuration drift. This forces a choice between reverting those edits or translating them manually into git. Objects added directly in the console present a tougher challenge: incorporating them into your state requires terraform import alongside an active identifier, which disappears the moment an item gets destroyed.
On a large tenant, the apply can then hit Okta's rate limits and stop partway, and Terraform doesn't roll back the half that already ran. That leaves the tenant somewhere between where it was and where you were trying to get it, with some objects recreated and others still missing. Nobody can say which until they read the next plan line by line.
Should the execution complete without errors, you are still left piecing together the unmapped memberships. That means sifting through System Log entries and writing custom scripts to reinstate users, assuming those log records fall within Okta's 90-day retention window. A SIEM keeps the history longer, but the script still gets written mid-incident. Every app assignment made outside the repo has to be found and redone, and anything that referenced the old group by ID has to be fixed too.
A deleted group is the easier case. If a user gets deleted (whether by a bad apply, a cleanup script or an attacker), Okta removes them from every group, app assignment and admin role at once—and the deletion can’t be undone. That’s the right behavior for a system whose job is to make removed access stick, but it means everything that person had must be rebuilt from somewhere else.
What No Tool Can Bring Back
Some of what a deleted object takes with it can't be restored by any tool, Terraform or otherwise. For good security reasons, Okta keeps three things out of reach of its API: device-bound factors (like Okta Verify and FIDO2), SAML signing keys, and API token values. A recreated user has to re-enroll those factors, and a recreated SAML app needs new metadata at each service provider. Any integration that used a lost API token needs a new one.
What Comes Back and What Doesn't
Here's how a typical Okta configuration comes through a reapply:
Okta object | Restored by a reapply? | What happens |
|---|---|---|
Policies and network zones in code | Yes | Defined in your configuration |
Groups in code | Yes, with a new ID | Terraform rebuilds the group and its settings from code |
Rule-driven memberships | Eventually | Okta re-evaluates the recreated rule asynchronously, which can take hours, and exceptions made outside code are lost |
Members added outside code | No | They were never in the repo, so someone rebuilds them from System Log events |
App assignments and policy rules set outside code | No | Assignments made outside code were removed with the old group, and anything that referenced it by ID now points at nothing |
Objects not in code that get deleted | No | There’s nothing to reapply, and terraform import needs an ID the deleted object no longer has |
Okta Workflows | No | The provider has no resource for flows |
The quickest way to see your own version of this table is to apply your repo into an empty preview org, then check whether people exist, which apps they can reach and whether they can sign in.
When the Pipeline is Part of the Problem
Mistakes aren't the only reason to recover. If an attacker gets admin access and starts changing groups and policies, you're facing the same reapply problems with less time and less certainty about what's safe.
Where a typical incident stems from a bad deployment, recovering after a breach forces you to examine your delivery infrastructure itself.
Terraform's state file holds sensitive values in plain text and the credentials your pipeline uses can change anything in the tenant. Before leveraging those automated pipelines to reconstruct your tenant, you must verify that neither component was tampered with during the intrusion.
What Good Recovery Looks Like
For IAM leaders, the critical metric is the duration between that initial access outage ticket arriving and the final ticket being resolved. Extended recovery windows complicate your compliance story and make it harder to show auditors who had access and when.
Terraform is still the right way to control changes to your Okta configuration. However, reliable recovery needs regular backups of the live tenant, so the memberships, assignments and objects that never lived in git can come back too. Those backups should be kept outside both the tenant and your pipeline, so you can restore from a point before the problem started even when you can’t trust the repo or the tenant as it is now. They should also let you restore a single group or app, with its memberships and assignments, without rolling back the whole tenant.
Rubrik Security Cloud can meet these requirements. It keeps point-in-time copies of Okta outside your tenant and relinks memberships and assignments when it recreates an object. Whatever you choose, run the preview-org test against it while things are calm.