-
-
Notifications
You must be signed in to change notification settings - Fork 149
auth0_role recreates roles if user got the role assigned #141
Comments
Hi @janfietz, could you provide some more elaborate reproduction steps? The example provided doesn't seem to have any relation to users. Perhaps the Auth0 dashboard does some kind of housekeeping and deletes a role if its unassociated from all users? Of course this is just a guess, any help to validate this would be helpful. |
Hi a minimal sample would be:
After apply it I used the auth0 dashboard to assign the role to my user. I tried to apply it again with following output:
Hope that helps. |
Hmm I think I understand whats going on. The user_ids are now changed since you’ve assigned a new user to that role. Perhaps user_ids are defined with forceNew, which will drop and recreate the resource. I am starting to believe that the best approach here is to split user assignment into its own resource (e.g. auth0_user_role) instead of letting the role own the relationship. I’ll try and give it a go tomorrow. Thanks @janfietz ! |
@janfietz I felt it easier to keep track of changes this way, as the role doesn't change, but who assumes the role does.
Also fixed some issues that user roles or role permissions wouldn't update correctly. Feel free to give it a try using |
@alexkappa i tested version v0.4.0 and it worked as expected. Good job. |
Community Note
Terraform Version
0.12.16
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
After creating the roles they should stay even if they got assigned to users.
Actual Behavior
Roles are destroyed and created. All users lost their assigned roles.
Steps to Reproduce
terraform apply
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: