Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

okta_policy_rule_signon identity_provider variable causing API error Invalid condition type specified: identityProvider #1079

Closed
mnovitsk opened this issue Apr 26, 2022 · 27 comments
Labels
bug priority-bug Class of bugs that are having issues when setting a priority property stale

Comments

@mnovitsk
Copy link

mnovitsk commented Apr 26, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v1.0.10
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.75.1
+ provider registry.terraform.io/okta/okta v3.25.0

Affected Resource(s)

  • resource.okta_policy_rule_signon
  • resource.okta_policy_signon

Terraform Configuration Files

resource "okta_policy_signon" "mnovitsk_policy" {
  name        = "mnovitsk_signon_policy"
  description = "Signon Policy for certain users"
  priority    = 1
  status      = "INACTIVE"
  groups_included = [
    resource.okta_group.mnovitsk_test.id
  ]
  depends_on = [
    resource.okta_group.mnovitsk_test
  ]
}

resource "okta_policy_rule_signon" "mnovitsk_policy_rule" {
  policy_id          = resource.okta_policy_signon.mnovitsk_policy.id
  status             = "INACTIVE"
  name               = "mnovitsk_signon_policy_rule"
  authtype           = "ANY"
  access             = "ALLOW"
  primary_factor     = "PASSWORD_IDP"
  network_connection = "ANYWHERE"
  session_idle       = 120 # 2 hour idle session
  session_lifetime   = 720 # 12 hour session lifetime
  depends_on = [
    resource.okta_policy_signon.mnovitsk_policy
  ]
}

Debug Output

Panic Output

Expected Behavior

Create a Global Session Policy (resource.okta_policy_signon) with a Policy Rule (resource.okta_policy_rule_signon)

Actual Behavior

Terraform errors out when trying to apply the configuration. It automatically supplies an identity_provider = "ANY" variable, even if it is not manually supplied, and then errors out. I encounter the same error when manually supplying identity_provider = "ANY" in the Terraform resource configuration.

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # okta_policy_rule_signon.mnovitsk_policy_rule will be created
  + resource "okta_policy_rule_signon" "mnovitsk_policy_rule" {
      + access              = "ALLOW"
      + authtype            = "ANY"
      + id                  = (known after apply)
      + identity_provider   = "ANY"
      + mfa_remember_device = false
      + mfa_required        = false
      + name                = "mnovitsk_signon_policy_rule"
      + network_connection  = "ANYWHERE"
      + policy_id           = (known after apply)
      + primary_factor      = "PASSWORD_IDP"
      + risc_level          = "ANY"
      + session_idle        = 120
      + session_lifetime    = 720
      + session_persistent  = false
      + status              = "INACTIVE"
    }

  # okta_policy_signon.mnovitsk_policy will be created
  + resource "okta_policy_signon" "mnovitsk_policy" {
      + description     = "Signon Policy for certain users"
      + groups_included = [
          + "<okta_group_id>",
        ]
      + id              = (known after apply)
      + name            = "mnovitsk_signon_policy"
      + priority        = 1
      + status          = "INACTIVE"
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

okta_policy_signon.mnovitsk_policy: Creating...
okta_policy_signon.mnovitsk_policy: Creation complete after 0s [id=00p3k04nmpYoSa3eq1d7]
okta_policy_rule_signon.mnovitsk_policy_rule: Creating...
╷
│ Error: failed to create sign-on policy rule: failed to create policy rule: the API returned an error: Api validation failed: conditions. Causes: errorSummary: conditions: Invalid condition type specified: identityProvider.
│ 
│   with okta_policy_rule_signon.mnovitsk_policy_rule,
│   on main.tf line 60, in resource "okta_policy_rule_signon" "mnovitsk_policy_rule":60: resource "okta_policy_rule_signon" "mnovitsk_policy_rule" {
│ 
╵
Releasing state lock. This may take a few moments...

Steps to Reproduce

  1. terraform apply

Important Factoids

References

I checked the Terraform Provider Documentation: https://registry.terraform.io/providers/okta/okta/latest/docs/resources/policy_rule_signon#identity_provider and it states that "Use of identity_provider requires a feature flag to be enabled.", but I do not see a flag in the tenant features related to this setting.

I am able to create Global Session Policies and Policy Rules via the UI with no issues, but attempting to create these resources via Terraform does not work. The policy itself is successfully created via Terraform, but there are no policy rules associated with it.

  • resource okta_policy_signon priority error #1028 : I also am experiencing a similar issue when trying to assign a specific priority to a new okta_policy_signon resource. I'm currently just providing priority = 1 to get around this issue for now, but it is going to cause larger problems when trying to declare and configure multiple sign on policies.
@monde monde self-assigned this Apr 26, 2022
@monde monde added the bug label Apr 26, 2022
@monde
Copy link
Collaborator

monde commented Apr 26, 2022

@mnovitsk I will look into this, seems like a regression off the just released v3.25.0. Can you pin your provider version to v3.24.0 and let me if you are seeing the correct behavior with that version?

@mnovitsk
Copy link
Author

mnovitsk commented Apr 26, 2022

@monde Pinning the Okta Provider version to v3.24.0 removed the identity_provider variable API error, thanks. I tested assigning the priority of the okta_signon_policy to be lower than the default policy and I got an error:

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # okta_policy_rule_signon.mnovitsk_policy_rule will be created
  + resource "okta_policy_rule_signon" "mnovitsk_policy_rule" {
      + access              = "ALLOW"
      + authtype            = "ANY"
      + id                  = (known after apply)
      + mfa_remember_device = false
      + mfa_required        = false
      + name                = "mnovitsk_signon_policy_rule"
      + network_connection  = "ANYWHERE"
      + policy_id           = (known after apply)
      + primary_factor      = "PASSWORD_IDP"
      + priority            = 1
      + risc_level          = "ANY"
      + session_idle        = 120
      + session_lifetime    = 720
      + session_persistent  = false
      + status              = "INACTIVE"
    }

  # okta_policy_signon.mnovitsk_policy will be created
  + resource "okta_policy_signon" "mnovitsk_policy" {
      + description     = "Signon Policy for certain users"
      + groups_included = [
          + "<okta_group_id>",
        ]
      + id              = (known after apply)
      + name            = "mnovitsk_signon_policy"
      + priority        = 3
      + status          = "INACTIVE"
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

okta_policy_signon.mnovitsk_policy: Creating...
╷
│ Error: failed to create sign-on policy: provided priority was not valid, got: 3, API responded with: 2. See schema for attribute details
│ 
│   with okta_policy_signon.mnovitsk_policy,
│   on main.tf line 47, in resource "okta_policy_signon" "mnovitsk_policy":47: resource "okta_policy_signon" "mnovitsk_policy" {
│ 
╵
Releasing state lock. This may take a few moments...

I realize that this is not necessarily tied to this bug and is more appropriate to #1028 , but can I assume that Okta always sets the Tenant's default policy to be the lowest priority and you cannot create or assign any sign on policies to be lower than the default policy?

@monde
Copy link
Collaborator

monde commented Apr 26, 2022

@mnovitsk I'm trying to get a bug fix out today and will address both the original bug and try to see if there is a fix and/or flexibility dealing with the error in v3.24.0 you are seeing.

@monde
Copy link
Collaborator

monde commented Apr 26, 2022

@mnovitsk I can't think of a way to deal with the priority issue with out hacking in retries. I've had a similar experience where I thought the API should correctly infer that if I add rules(s) mixed with existing rules, it should be able know the new position of existing rules. Like if there is a default rule which is 1. Then if I add two new rules, one priority 1, and the other priority 3; thinking that that the API will flexibly make the existing rule be priority 2. I just had to run my apply a couple of times.

Here, I ran into that when I was working on enrollment policies.

image

image

@monde
Copy link
Collaborator

monde commented Apr 26, 2022

I have a fix queued up in PR #1081 and am waiting for a colleague to review it before releasing.

@monde monde closed this as completed in 0ebeae7 Apr 26, 2022
@monde
Copy link
Collaborator

monde commented Apr 27, 2022

v3.25.1 is available in the terraform registry

MikeMondragon-okta pushed a commit that referenced this issue May 23, 2022
setup around SPECIFIC_IDP. Passing ACC tests:
- TestAccOktaPolicyRuleSignon_crud
- TestAccOktaPolicySignOn_defaultError
- TestAccOktaPolicySignOn_crud
Closes #1126
Reopens #1079
@monde monde reopened this May 24, 2022
@monde
Copy link
Collaborator

monde commented May 24, 2022

@mnovitsk I reopened this issue. I had to revert part of this change and it was released as v3.28.0 https://github.com/okta/terraform-provider-okta/releases/tag/v3.28.0 . Can you take a moment if this issue would occur again for you? Feel free to close the issue if you are good.

@miguelpuiggarcia
Copy link

Hi @monde This issue is happening again with version v3.28.0 if this helps
Error: failed to update sign-on policy rule: the API returned an error: Api validation failed: conditions. Causes: errorSummary: conditions: Invalid condition type specified: identityProvider.

@monde
Copy link
Collaborator

monde commented May 25, 2022

@miguelpuiggarcia @mnovitsk I'll make it a priority to get to the bottom of this today and do a patch release ASAP

@lucascantor
Copy link
Contributor

@monde to confirm, is this bug still expected to impact today's new 3.29.0 release?

@monde
Copy link
Collaborator

monde commented Jun 10, 2022

@lucascantor I've not had a chance to look at this one yet, nothing related to it is in v3.29.0

@tim-fitzgerald
Copy link
Contributor

Just adding my voice here. Experiencing this on 3.29.0. If I can provide any useful info @monde please let me know.

@monde monde added the priority-bug Class of bugs that are having issues when setting a priority property label Jun 27, 2022
@Mrorya
Copy link

Mrorya commented Jun 28, 2022

This bug is still present in 3.30.0

@lucascantor
Copy link
Contributor

lucascantor commented Jul 9, 2022

Looks like this bug is still present in 3.31.0 as well.

I'm sorry I don't understand the nature of the root cause to offer a fix ☹️ Is there perhaps a workaround that allows use of okta_policy_rule_signon resources until this is fixed though?

We're stuck on 3.27.0 because of this, and can't make use of other important bug fixes in newer releases.

I imagine nearly every Okta customer using the Okta Terraform provider also has okta_policy_rule_signon resources, putting them in a similar predicament.

@tmatilai
Copy link

tmatilai commented Jul 9, 2022

Is there perhaps a workaround that allows use of okta_policy_rule_signon resources until this is fixed though?

Can't test it now, but ignoring the attribute should work. Something like:

resource "okta_policy_rule_signon" "example" {
  lifecycle {
    ignore_changes = [identity_provider]
  }
  # ...
}

We're stuck on 3.27.0 because of this, and can't make use of other important bug fixes in newer releases.

By splitting the Okta configurations into multiple root modules, you might be able to use the newer version where needed, while pinning down the version only where you are affected by a certain bug.

@tmatilai
Copy link

tmatilai commented Jul 9, 2022

Can't test it now, but ignoring the attribute should work

And if it doesn't work in initial creation of the resource, at least by creating the rule manually and then importing to the state, the ignore_changes should do its job.

@lucascantor
Copy link
Contributor

@tmatilai thanks so much for the advice 🙇🏼

@monde
Copy link
Collaborator

monde commented Jul 9, 2022

This one is still on my todo list. I'm on vacation for a week and can give it priority when I get back.

@monde
Copy link
Collaborator

monde commented Jul 9, 2022

"bug(s) with resources having a priority setting" #1198

@tmatilai
Copy link

@monde while the problem with priority bug is real and annoying, IMHO the main issue here is the identityProvider attribute (as stated in the subject). To my understanding it's behind a feature flag in the Okta tenant configurations, and without enabling, the API doesn't like to see it used. Right?

Would removing the default value be sufficient fix? Or should the API be changed to ignore the attribute?

@lucascantor
Copy link
Contributor

I can confirm adding

lifecycle {
    ignore_changes = [identity_provider]
}

resolves my issue, allowing me to use 3.31.0.

@monde monde removed their assignment Aug 15, 2022
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label Oct 25, 2022
@lucascantor
Copy link
Contributor

This bug still exists. Commenting to prevent auto-closure.

@monde monde removed the stale label Oct 25, 2022
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label Jan 11, 2023
@lucascantor
Copy link
Contributor

Not stale

@monde monde removed the stale label Jan 11, 2023
@monde
Copy link
Collaborator

monde commented Mar 10, 2023

"0" zero value integers was fixed in v3.44.0 release. I'm not sure that will benefit anything here. Looking for feedback.

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label May 10, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug priority-bug Class of bugs that are having issues when setting a priority property stale
Projects
None yet
Development

No branches or pull requests

7 participants