okta / terraform-provider-okta

A Terraform provider to manage Okta resources, enabling infrastructure-as-code provisioning and management of users, groups, applications, and other Okta objects.
https://registry.terraform.io/providers/okta/okta
Mozilla Public License 2.0
255 stars 207 forks source link

`okta_policy_mfa_default` sending priority from terraform state causes API errors #2107

Open tmonck opened 1 day ago

tmonck commented 1 day ago

Community Note

Terraform Version

Terraform v1.9.8
on darwin_arm64
+ provider registry.terraform.io/okta/okta v4.11.0

Affected Resource(s)

Terraform Configuration Files

resource "okta_policy_mfa_default" "default_policy" {
  is_oie = false

  okta_otp = {
    enroll = "OPTIONAL"
  }

  google_otp = {
    enroll = "OPTIONAL"
  }

  okta_email = {
    enroll = "REQUIRED"
  }
}

Debug Output

β”‚ Error: failed to update default MFA policy: the API returned an error: Cannot modify the priority attribute because it is read-only. β”‚ β”‚ with okta_policy_mfa_default.default_policy, β”‚ on mfa.tf line 25, in resource "okta_policy_mfa_default" "default_policy": β”‚ 25: resource "okta_policy_mfa_default" "default_policy" { β”‚

Panic Output

Expected Behavior

The default MFA policy should not error during updates.

Can this be done in the Admin UI?

No

Can this be done in the actual API call?

I don't know

Actual Behavior

The default MFA policy errors out due to priority being passed.

Steps to Reproduce

  1. terraform apply
  2. Add another mfa policy either via the UI
  3. terraform apply
  4. Remove the newly added policy via the UI
  5. terraform apply
  6. Update the terraform to have a modification on the default MFA policy. (Change something from required to optional or not allowed)
  7. terraform apply

Step 7 should error out.

Any changes that cause the priority value in the terraform state to differ from what is actually returned via the API for policies seems to trigger the error condition.

Important Factoids

References

duytiennguyen-okta commented 4 hours ago

OKTA internal reference https://oktainc.atlassian.net/browse/OKTA-822267