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

data_source_okta_users omits admin_roles #1014

Closed
exitcode0 opened this issue Mar 11, 2022 · 6 comments
Closed

data_source_okta_users omits admin_roles #1014

exitcode0 opened this issue Mar 11, 2022 · 6 comments

Comments

@exitcode0
Copy link
Contributor

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.11
on darwin_arm64
+ provider registry.terraform.io/okta/okta v3.22.0

Affected Resource(s)

  • data_source_okta_users

Terraform Configuration Files

data "okta_users" "BLAH" {
  search {
    name = "profile.login"
    comparison = "eq"
    value = "exact.email.address@domain.com"
  }
}

output "testing" {
  value = data.okta_users.BLAH.users
}

output "testing2" {
  value = [for user in data.okta_users.BLAH.users : user.id if length(user.admin_roles) > 0]
}

Debug Output

Panic Output

Expected Behavior

when the user in question is a super admin, i'd expect testing2 output to contain the users ID and testing1 to contain an entry similar to "admin_roles" = toset(["SUPER_ADMIN"])

Actual Behavior

the output testing2 outputs as empty and testing1 correctly outputs the user object but the admins roles entry shows as "admin_roles" = toset([])

Steps to Reproduce

  1. terraform refresh

Important Factoids

References

  • #0000
@monde monde self-assigned this Mar 11, 2022
@monde monde added the needs-investigation Needs further investigation label Mar 11, 2022
@monde
Copy link
Collaborator

monde commented Mar 11, 2022

Thanks @exitcode0 I'll look into this, thanks!

@exitcode0
Copy link
Contributor Author

it seems that data_source_okta_users calls /api/v1/users
which does not return admin roles for the users

the documentation for the datasource Here would suggest that this is possible

So I guess either the doco here is missleading and should be updated or the implementation or data_source_okta_users needs to be changed to include this as an option
perhaps with a skip_roles similar to data_source_okta_user with a default value of true

@exitcode0
Copy link
Contributor Author

My workaround for this for now in case someone else comes across this issue

resource "okta_resource_set" "okta_admins" {
  label       = "okta_admins"
  description = "okta_admins"

  resources = [
    "https://${local.org_name}.${local.base_url}/api/v1/groups/${okta_group.okta_admins.id}/users",
  ]
}
resource "okta_group" "okta_admins" {
  name        = "okta_admins"
  description = "Users with okta admin permissions. Membership to this group is managed by terraform."
  skip_users  = true

}
resource "okta_group_memberships" "okta_admins" {
  group_id = okta_group.okta_admins.id
  users = [
    for user in data.okta_app_user_assignments.okta_admin_console.users :
    user
  ]
}
data "okta_app" "okta_admin_console" {
  label = "Okta Admin Console"
}
data "okta_app_user_assignments" "okta_admin_console" {
  id = data.okta_app.okta_admin_console.id
}

@monde monde removed the needs-investigation Needs further investigation label Apr 25, 2022
@monde monde added the bug label Jun 8, 2022
@monde
Copy link
Collaborator

monde commented Jun 8, 2022

being addressed in #1159

@github-actions
Copy link

github-actions bot commented Aug 8, 2022

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 Aug 8, 2022
@monde monde added no-stalebot and removed stale labels Aug 8, 2022
@monde monde removed their assignment Aug 15, 2022
@monde monde removed the no-stalebot label Oct 24, 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 20, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants