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

Is there an option to avoid giving an API key and directly provide the resource with IBM IAM tokens ? #453

Closed
nicholas-bn opened this issue Nov 28, 2023 · 1 comment

Comments

@nicholas-bn
Copy link

Hi,

Is there a way to use the provider by giving the IAM tokens directly instead of passing an API key that'll generate those tokens ?

Thank you very much.

@dbonf
Copy link
Collaborator

dbonf commented Jan 10, 2024

Hi, you can skip using the ibm_monitor_ parameters and you can pass IBMInstanceID via extra_headers, example:

provider "sysdig" {
  sysdig_monitor_url = "https://eu-gb.monitoring.cloud.ibm.com"
  sysdig_monitor_api_token = "your temporary iam token"
  extra_headers = {
    IBMInstanceID = "xxx"
  }
}

For example, you can generate temporary iam token with the resource ibm_iam_auth_token of the ibm terraform provider and use this:

provider "ibm" {
  ibmcloud_api_key = "xxxx"
}

data "ibm_iam_auth_token" "tokendata" {}

provider "sysdig" {
  sysdig_monitor_url       = "https://eu-gb.monitoring.cloud.ibm.com"
  sysdig_monitor_api_token = trimprefix(data.ibm_iam_auth_token.tokendata.iam_access_token, "Bearer ")
  extra_headers = {
    IBMInstanceID = "xxxx"
  }
}

You can also just use extra_headers but, since ibm_monitor_api_key or sysdig_monitor_api_token is required, you need to add dummy values there and the Authorization header will be replaced, example:

provider "ibm" {
  ibmcloud_api_key = "xxx"
}

data "ibm_iam_auth_token" "tokendata" {}

provider "sysdig" {
  sysdig_monitor_url       = "https://eu-gb.monitoring.cloud.ibm.com"
  sysdig_monitor_api_token = "dummy"
  extra_headers = {
    IBMInstanceID = "xxx"
    Authorization = data.ibm_iam_auth_token.tokendata.iam_access_token
  }
}

@dbonf dbonf closed this as completed Feb 1, 2024
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

2 participants