confluentinc / terraform-provider-confluent

Terraform Provider for Confluent
Apache License 2.0
118 stars 61 forks source link

Azure Devops Collision with ENVIRONMENT_ID #369

Closed JeffSBailey closed 3 months ago

JeffSBailey commented 3 months ago

In a confluent terraform release > 1.61, a change was introduced in the provider config to require that all "7" attributes of the flink provider be set or none be set. The simple terraform below, when run from the shell in an Azure Devops task will result in an error

All 7 flink_api_key, flink_api_secret, flink_rest_endpoint, organization_id, environment_id, flink_compute_pool_id, flink_principal_id attributes should be set or not set in the provider block at the same time

Azure Devops sets an ENVIRONMENT_ID variable that is causing this issue.

terraform {
  required_version = ">=1.7.1"

  required_providers {

    confluent = {
      source  = "confluentinc/confluent"
      version = "1.65.0"
    }
  }
}
variable "cloud_api_secret" {
  type = string
}
provider "confluent" {
  cloud_api_key         = "key here"
  cloud_api_secret      = var.cloud_api_secret
}

data "confluent_environment" "current" {
  id = "id here"
}

Current workarounds:

  1. run unset ENVIRONMENT_ID prior to terraform plan.

  2. Add to the providers section environment_id = "" Note that this makes intellisense mad because environment_id isn't an official property of the confluent provider. It does allow it to go through, however.

linouk23 commented 3 months ago

@JeffSBailey thanks for creating the issue!

Your error implies at least one of these env vars are set (seems like it's ENVIRONMENT_ID):

All 7 flink_api_key, flink_api_secret, flink_rest_endpoint, organization_id, environment_id, flink_compute_pool_id, flink_principal_id attributes should be set or not set in the provider block at the same time

Is there a way not to set ENVIRONMENT_ID as environment variable?

It seems we could alternatively rename ENVIRONMENT_ID to CONFLUENT_ENVIRONMENT_ID.

JeffSBailey commented 3 months ago

It is automatically set by the azure devops pipeline when using an azure devops environment. The only way that I could find around it is to either manually unset the environment variable (not sure if that will cause any issues later) or send in a blank string to the provider. It would be great if there was a CONFLUENT_ prefix required for ENVIRONMENT_ID and ORGANIZATION_ID.

linouk23 commented 3 months ago

Oh I see, that makes a lot of sense!

We'll apply this suggestion in our next release:

It would be great if there was a CONFLUENT_ prefix required for ENVIRONMENT_ID and ORGANIZATION_ID.

and update this thread once it's released 👍

linouk23 commented 3 months ago

@JeffSBailey we're happy to let you know that the fix has been implemented in our latest version of TF Provider (1.66.0).