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

Resource to send a Private Catalog & accept #5436

Open
pauljegouic opened this issue Jun 18, 2024 · 0 comments
Open

Resource to send a Private Catalog & accept #5436

pauljegouic opened this issue Jun 18, 2024 · 0 comments
Labels
enhancement service/Catalog Management Issues related to Catalog Management

Comments

@pauljegouic
Copy link

Hello there,

I would like to have the ability to manage the share requests and approval process by automation in the Private Catalog.

image

I would need something to be able to send/revoke a request from an account, and the ability to accept/revoke the request received on the target account.

Here is my functional attempt to perform it :

# SOURCE ACCOUNT
resource "null_resource" "share_catalog_access" {
  triggers = {
    always_run = "${timestamp()}"
  }
  provisioner "local-exec" {
    command = <<EOT
         IC_API_KEY=${var.iz_admin_api_key}
          export TOKEN=$(curl -X POST "https://iam.cloud.ibm.com/identity/token" --header 'Content-Type: application/x-www-form-urlencoded'   --header 'Accept: application/json'   --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey'   --data-urlencode "apikey=$IC_API_KEY" | jq -r .access_token)

          res=$(curl -v -X "POST" "https://cm.globalcatalog.cloud.ibm.com/api/v1-beta/shareapproval/offering/access" -H "accept: */*" -H "Authorization: Bearer $TOKEN" --data-raw '["-acct-${data.ibm_iam_account_settings.iam_account_settings.account_id}"]')
        EOT
  }
}

#TARGET ACCOUNT 
resource "null_resource" "accept_catalog_request" {
  depends_on = [null_resource.share_catalog_access]
  triggers = {
    always_run = "${timestamp()}"
  }
  provisioner "local-exec" {
    command = <<EOT
         if [ ! -z $IC_IAM_TOKEN ]
          then
              export TOKEN="$IC_IAM_TOKEN"
          else
              export TOKEN=$(curl -X POST "https://iam.cloud.ibm.com/identity/token" --header 'Content-Type: application/x-www-form-urlencoded'   --header 'Accept: application/json'   --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey'   --data-urlencode "apikey=$IC_API_KEY" | jq -r .access_token)
          fi

          res=$(curl -v -X "POST" "https://cm.globalcatalog.cloud.ibm.com/api/v1-beta/shareapproval/offering/access/source/approved" -H "accept: */*" -H "Authorization: Bearer $TOKEN" --data-raw '["-acct-1ccbee2da57a496badb5e5ec00f8158d"]')
        EOT
  }
}

Obviously this would require a multi provider context.

@hkantare hkantare added the service/Catalog Management Issues related to Catalog Management label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement service/Catalog Management Issues related to Catalog Management
Projects
None yet
Development

No branches or pull requests

2 participants