DeviaVir / terraform-provider-gsuite

A @HashiCorp Terraform provider for managing G Suite resources.
MIT License
271 stars 77 forks source link

Add Data Source for `Roles` and Resource for `RoleAssignment` #147

Open megan07 opened 4 years ago

megan07 commented 4 years ago

It'd be nice to create RoleAssignments so we can add admin roles to service accounts as explained here: https://github.com/terraform-providers/terraform-provider-google/issues/6704#issuecomment-651285723

This would likely require a data source for roles as well.

Something like

data "gsuite_roles" "roles" {
  customer_id = "Cust0123id"
  filter {
    name = "items.role_name"
    value = "_GROUPS_ADMIN_ROLE"
  }
}

data "google_service_account" "my-sa" {
  account_id = "my-service-account"
}

resource "gsuite_role_assignment" "group_admin" {
  customer_id = "Cust0123id"
  assigned_to  = google_service_account.my-sa.unique_id
  role_id = gsuite_roles.0.role_id
  scope_type = "customer" 
}