confluentinc / terraform-provider-confluent

Terraform Provider for Confluent
Apache License 2.0
27 stars 63 forks source link

fix: use provider credentials if they are set in extractClusterApiKeyAndApiSecret #328

Open jaylevin opened 10 months ago

jaylevin commented 10 months ago

Current behavior: With the following API Key based provider authentication:

# Option #1: Manage multiple clusters in the same Terraform workspace
provider "confluent" {
  cloud_api_key    = var.confluent_cloud_api_key    # optionally use CONFLUENT_CLOUD_API_KEY env var
  cloud_api_secret = var.confluent_cloud_api_secret # optionally use CONFLUENT_CLOUD_API_SECRET env var
}

Any CRUD operations on a kafka_acl results in the ACL's referenced credentials being used for authentication instead of the cloud_api_key and cloud_api_secret defined in the provider block.

Expected behavior:

I would expect the creation, reading, deletion, or update of a kafka_acl to use the provider's configured APIKey/secret defined in the provider "confluent" { .. } block.

However, because isKafkaMetadataSet checks for the kafka_rest_endpoint to be set in order for the provider's APIkey/secret to be used for CRUD of a kafka_acl, this is not happening. Instead the CRUD operations of a KafkaACL are using the API Key referenced in the kafka_acl's credentials block. Essentially this block is executed instead of this one.

I am wondering if there is a specific reason why the confluent provider is using the ACL's referenced credentials for authentication versus the credentials defined in the provider block? If there is no special reason for this, I think #328 would be a good solution for this problem.

fixes #329

cla-assistant[bot] commented 10 months ago

CLA assistant check
All committers have signed the CLA.

jaylevin commented 10 months ago

@linouk23 Let me know if this change makes sense to you, or if you have any questions/concerns regarding the change. Thanks!