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

Feature Request: data_ibm_iam_access_group #953

Closed
jamestalton opened this issue Dec 16, 2019 · 4 comments
Closed

Feature Request: data_ibm_iam_access_group #953

jamestalton opened this issue Dec 16, 2019 · 4 comments

Comments

@jamestalton
Copy link

jamestalton commented Dec 16, 2019

I have a use case where when running against different regions I need access to an existing ibm_iam_access_group. There is currently no data provider for accessing an existing ibm_iam_access_group.

@data-henrik
Copy link
Contributor

is this addressed now?

@jkayani
Copy link

jkayani commented Jul 6, 2020

I believe this is broken currently based on this TF plan output:

# ibm_iam_access_group_members.conductor-members will be created
  + resource "ibm_iam_access_group_members" "conductor-members" {
      + access_group_id = "ACCOUNT-ID"
      + ibm_ids         = [
         + REDACTED
        ]
      + id              = (known after apply)
      + members         = (known after apply)
    }
  # ibm_iam_access_group_policy.conductor-policy will be created
  + resource "ibm_iam_access_group_policy" "conductor-policy" {
      + access_group_id    = "ACCOUNT-ID"
      + account_management = false
      + id                 = (known after apply)
      + roles              = [
          + "Viewer",
          + "Reader",
          + "Writer",
        ]
      + version            = (known after apply)
      + resources {
          + attributes           = {
              + "namespace" = "conductor"
            }
          + resource_group_id    = "REDACTED"
          + resource_instance_id = "REDACTED"
          + service              = "containers-kubernetes"
        }
    }

Basically everywhere it says ACCOUNT-ID it fills in the actual ID of the IBM Cloud account you're using with Terraform, when it really should be the ID of the actual access group. Everything else seems right. Looking at the UI, access group ID's are of the form: AccessGroupId-<some-string>

@jkayani
Copy link

jkayani commented Jul 6, 2020

Actually I figured it out: the docs are correct though the behavior is a bit confusing. When passing an access group name as a parameter to the AG data source, you will still be returned a list containing the single matching access group.

So do this:

data "ibm_iam_access_group" "<thing>" {
  access_group_name = "Conductor"
}

resource "ibm_iam_access_group_members" "conductor-members" {
  access_group_id = data.ibm_iam_access_group.<thing>.groups[0].id
  ...
}

to get this output from TF plan:

  # ibm_iam_access_group_members.conductor-members will be created
  + resource "ibm_iam_access_group_members" "conductor-members" {
      + access_group_id = "AccessGroupId-REDACTED"
      + ibm_ids         = [
         REDACTED
        ]
      + id              = (known after apply)
      + members         = (known after apply)
    }
  # ibm_iam_access_group_policy.conductor-policy will be created
  + resource "ibm_iam_access_group_policy" "conductor-policy" {
      + access_group_id    = "AccessGroupId-REDACTED"
      + account_management = false
      + id                 = (known after apply)
      + roles              = [
          + "Viewer",
          + "Reader",
          + "Writer",
        ]
      + version            = (known after apply)
      + resources {
          + attributes           = {
              + "namespace" = "conductor"
            }
          + resource_group_id    = "REDACTED"
          + resource_instance_id = "REDACTED"
          + service              = "containers-kubernetes"
        }
    }

The reason the account ID can be obtained as data.ibm_iam_access_group.<thing>.id is because of this: https://github.com/IBM-Cloud/terraform-provider-ibm/blob/master/ibm/data_source_ibm_iam_access_group.go#L194

@hkantare
Copy link
Collaborator

hkantare commented Jul 7, 2020

Yes the output from the ibm_iam_access_group is a list of groups..because we can have multiple access groups with same name so we are listing back all the grps...

@hkantare hkantare closed this as completed Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants