coralogix/terraform-provider-coralogix

Provider is not consistent in choosing the api key

Opened this issue ยท 0 comments

Affected Resource(s)

  • coralogix_alert (at least)

Terraform Configuration Files

Here is an example of the terraform file:

provider "coralogix" {
  api_key = <api key>
  env     = "USA1"
}

resource "coralogix_webhook" "this" {
  name  = "#test"
  slack = {
    notify_on = null
    url       = "https://example.com"
  }
}


resource "coralogix_alert" "this" {
  name        = "Coralogix Alert"
  description = "Coralogix Alert."
  
  severity    = "Critical"

  notifications_group {
    notification {
      notify_on                   = "Triggered_and_resolved"
      integration_id              = coralogix_webhook.this.external_id
      retriggering_period_minutes = 60
    }
  }

  metric {
    promql {
      search_query = "k8s_daemonset_desired_scheduled_nodes__node_"
      condition {
        more_than                      = true
        threshold                      = 0
        sample_threshold_percentage    = 40
        time_window                    = "5Min"
        min_non_null_values_percentage = 10
      }
    }
  }
}

Expected Behavior

Both webhook and alert to be created.

Actual Behavior

Webhook gets created but not the alert.

~/temp/tf on ๐Ÿ…ฐ admin-org (eu-west-2) โ˜ธ arn:aws:eks:us-east-1:804670868283:cluster/eks-blue took 3s at 16:28:52 โฏ CORALOGIX_API_KEY=test t apply
data.honeycombio_auth_metadata.current: Reading...
data.honeycombio_auth_metadata.current: Read complete after 0s
data.honeycombio_environments.current: Reading...
data.honeycombio_environments.current: Read complete after 0s [id=1552630114]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # coralogix_alert.this will be created
  + resource "coralogix_alert" "this" {
      + description = "Coralogix Alert."
      + enabled     = true
      + id          = (known after apply)
      + name        = "Coralogix Alert"
      + severity    = "Critical"

      + metric {
          + promql {
              + search_query = "k8s_daemonset_desired_scheduled_nodes__node_"

              + condition {
                  + min_non_null_values_percentage = 10
                  + more_than                      = true
                  + sample_threshold_percentage    = 40
                  + threshold                      = 0
                  + time_window                    = "5Min"
                }
            }
        }

      + notifications_group {
          + group_by_fields = []

          + notification {
              + email_recipients            = []
              + integration_id              = (known after apply)
              + notify_on                   = "Triggered_and_resolved"
              + retriggering_period_minutes = 60
            }
        }
    }

  # coralogix_webhook.this will be created
  + resource "coralogix_webhook" "this" {
      + external_id = (known after apply)
      + id          = (known after apply)
      + name        = "#test"
      + slack       = {
          + url = "https://example.com"
        }
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

coralogix_webhook.this: Creating...
coralogix_webhook.this: Creation complete after 1s [id=1bc549bd-7908-4888-9079-6d84db594fcf]
coralogix_alert.this: Creating...
โ•ท
โ”‚ Error: rpc error: code = Unauthenticated desc = c5e597274094beff3ed21416556add2a344b6f11
โ”‚ 
โ”‚   with coralogix_alert.this,
โ”‚   on coralogix.tf line 30, in resource "coralogix_alert" "this":
โ”‚   30: resource "coralogix_alert" "this" {
โ”‚ 
โ•ต

Steps to Reproduce

Caught an issue while running terraform with the provider explicitly configured with the api key from secret manager for one team while the pipeline already had set CORALOGIX_API_KEY to api key from another team.

  1. CORALOGIX_API_KEY=test terraform apply

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment