Closed lucascantor closed 3 years ago
Hi @lucascantor! Thanks for submitting this issue! I'll try to reproduce the scenario you've provided and fix the problem.
Hi @lucascantor! I've used this scenario to reproduce the issue (I'm using Terraform v1.0.6)
terraform apply
to create these resources
resource "okta_group" "test" {
name = "testAcc_replace_with_uuid"
description = "testing"
lifecycle {
ignore_changes = [users]
}
}
resource "okta_group_role" "test" { group_id = okta_group.test.id role_type = "READ_ONLY_ADMIN" }
resource "okta_group" "test_target1" { name = "testTarget1Acc_replace_with_uuid" description = "testing" }
resource "okta_group" "test_target2" { name = "testTarget2Acc_replace_with_uuid" description = "testing" }
resource "okta_group_role" "test_app" { group_id = okta_group.test.id role_type = "GROUP_MEMBERSHIP_ADMIN" target_group_list = [okta_group.test_target1.id, okta_group.test_target2.id] }
2. Edit `okta_group_role.test_app` to have only one item in the `target_group_list` and run `terraform apply`
//...
resource "okta_group_role" "test_app" { group_id = okta_group.test.id role_type = "GROUP_MEMBERSHIP_ADMIN" target_group_list = [okta_group.test_target2.id] }
Output:
```Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# okta_group_role.test_app will be updated in-place
~ resource "okta_group_role" "test_app" {
id = "I5JE6VKQL5GUKTKCIVJFGSCJKBPUCRCNJFHA"
~ target_group_list = [
- "00g11jl6x78hYw8Az0h8",
# (1 unchanged element hidden)
]
# (2 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Remove target_group_list
field from the okta_group_role.test_app
resource and run terraform apply
resource "okta_group_role" "test_app" {
group_id = okta_group.test.id
role_type = "GROUP_MEMBERSHIP_ADMIN"
}
Output:
Terraform will perform the following actions:
# okta_group_role.test_app must be replaced
-/+ resource "okta_group_role" "test_app" {
~ id = "I5JE6VKQL5GUKTKCIVJFGSCJKBPUCRCNJFHA" -> (known after apply)
- target_group_list = [
- "00g11jl8q84lPZXSB0h8",
] -> null # forces replacement
# (2 unchanged attributes hidden)
}
Plan: 1 to add, 0 to change, 1 to destroy.
Now terraform forces replacement of the `okta_group_role.test_app` resource. The reason for this behavior can be found in the API docs:
Note: Don't remove the last Group target from a role assignment, as it causes an exception. If you need a role assignment that applies to all Groups, the API consumer should delete the role assignment and recreate it.
The actual error from the API
Error: failed to remove group target from admin role assignment I5JE6VKQL5GUKTKCIVJFGSCJKBPUCRCNJFHA of group 00g11jl08ouOSS9AC0h8: the API returned an error: The provided role type was not the same as required role type., Status: 405 Method Not Allowed
Ok, now I get the problem. I'm not sure why this is happening, but if I remove "GROUP_MEMBERSHIP_ADMIN"
role from the group and then add it back, the ID of "READ_ONLY_ADMIN"
role will change. That's a very weird behavior and I'll ask the team responsible for this functionality what may cause this problem.
@bogdanprodan-okta thanks so much for this. I thought I was losing my mind, but I'm glad to know it's not just me.
@lucascantor we have a conversation started with the team in Okta core that will help us get the upstream issue fixed.
@lucascantor I will create a workaround for this. Basically, I will hot-swap the ID, so only this message might appear.
Terraform detected the following changes made outside of Terraform since the last "terraform apply":
# okta_group_role.test has been changed
~ resource "okta_group_role" "test" {
~ id = "gra11jyo80pMq1UL20h8" -> "gra11jyrcuaHbVIDx0h8"
# (2 unchanged attributes hidden)
}
Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.
────────────────────────────────────────────────────────
No changes. Your infrastructure matches the configuration.
I know it's not the best solution, but at least it fixes the problem for now.
@bogdanprodan-okta thank you! This is still infinitely better than the current behavior 🙏🏼
@lucascantor this issue is resolved and right now this is behind an ENG
flag to be rolled out to preview in the next monthly release. In the meantime, you can make a request to the support so they enable this flag ENG_GROUP_ROLE_ASSIGNMENT_PERF_AND_SIMPLIFY
.
Community Note
Terraform Version
Affected Resource(s)
okta_group_role
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
okta_group_role.okta_admin_it_read_only
should not incorrectly be identified as deleted.Actual Behavior
okta_group_role.okta_admin_it_read_only
is incorrectly identified as deleted.Steps to Reproduce
okta_group_role
withrole_type = "READ_ONLY_ADMIN"
assigned to a groupokta_group_role
withrole_type = "GROUP_MEMBERSHIP_ADMIN"
assigned to the same groupterraform apply
target_group_list
for theokta_group_role
withrole_type = "GROUP_MEMBERSHIP_ADMIN"
terraform apply
The subsequent
terraform_plan
will result in the following, which will cause an Okta API error if applied:Important Factoids
References