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
258 stars 208 forks source link

okta_group_rule.remove_assigned_users = True fails to remove users when deleting rule #2082

Open RGVas opened 1 month ago

RGVas commented 1 month ago

Community Note

Terraform Version

1.9.5

Affected Resource(s)

okta_group_rule

Terraform Configuration Files

resource "okta_group_rule" "example" {
  name                  = "example"
  status                = "ACTIVE"
  group_assignments     = [okta_group_example.id]
  expression_type       = "urn:okta:expression:1.0"
  expression_value      = "String.startsWith(user.firstName,\"andy\")"
  remove_assigned_users = true
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

Once the rule is deleted all users assigned by the rule should be unassigned from the group

Can this be done in the Admin UI?

I don't know

Can this be done in the actual API call?

Yes

https://developer.okta.com/docs/api/openapi/okta-management/management/tag/GroupRule/#tag/GroupRule/operation/deleteGroupRule

Actual Behavior

Users are not removed from the group set by the rule when using remove_assigned_users = true. Instead their managed status changes from "By rule" to "Manually"

Steps to Reproduce

  1. Create a group rule
  2. terraform apply
  3. Delete group rule
  4. terraform apply

Important Factoids

N/A

References

N/A

RGVas commented 1 month ago

I've raised a PR for this here

arvindkrishnakumar-okta commented 1 month ago

@RGVas Thanks for your PR! I'll review it and get it merged soon.

If not already, can you please sign the CLA here?