Mongey / terraform-provider-kafka

Terraform provider for managing Apache Kafka Topics + ACLs
MIT License
517 stars 129 forks source link

Getting DEPRECATED messages when using environment variables for provider #108

Open Constantin07 opened 4 years ago

Constantin07 commented 4 years ago

I'm using environment variables to pass credentials to Kafka provider, e.g.

KAFKA_CA_CERT - The CA certificate
KAFKA_CLIENT_CERT - The client certificate
KAFKA_CLIENT_KEY - The private key of client

Provider configuration :

provider "kafka" {
  version           = "0.2.4"
  bootstrap_servers = split(",", data.aws_msk_cluster.this.bootstrap_brokers_tls)
  tls_enabled       = true
  skip_tls_verify   = false
}

when I ran the plan I get this:

Warning: "ca_cert_file": [DEPRECATED] This parameter is now deprecated and will be removed in a later release, please use `ca_cert` instead.

Warning: "client_cert_file": [DEPRECATED] This parameter is now deprecated and will be removed in a later release, please use `client_cert` instead.

Warning: "client_key_file": [DEPRECATED] This parameter is now deprecated and will be removed in a later release, please use `client_key` instead.

This is confusing as I'm not using the configuration parameters in provider - neither old names nor new ones.

Looks like this is happening because both old and new config parameters are mapped to the same environment variables, e.g.

Is it supposed to work like that ?

Constantin07 commented 4 years ago

What's strange - if I deploy kafka_acls resources - I don't get those warning but if I deploy topics - I do.

matthewhughes-uw commented 6 months ago

Looks like this is happening because both old and new config parameters are mapped to the same environment variables

Specifically:

So if you set KFAKA_CA_CERT I guess both get set, resulting in a deprecation warning from ca_cert_file.

I wonder if this can be avoided by adding another env var for ca_cert (the naming is a bit unfortunate, since the deprecated var already makes use of KAFKA_CA_CERT which is what ca_cert would naturally map to):

diff --git a/kafka/provider.go b/kafka/provider.go
index 58fcabb..770380d 100644
--- a/kafka/provider.go
+++ b/kafka/provider.go
@@ -40,7 +40,7 @@ func Provider() *schema.Provider {
                        "ca_cert": {
                                Type:        schema.TypeString,
                                Optional:    true,
-                               DefaultFunc: schema.EnvDefaultFunc("KAFKA_CA_CERT", nil),
+                               DefaultFunc: schema.MultiEnvDefaultFunc([]string{"KAFKA_CA_CERT", "KAFKA_CA_CERT_FILE"}, nil),
                                Description: "CA certificate file to validate the server's certificate.",
                        },
                        "client_cert": {

EDIT: and further, the same issue for:

scanchon commented 3 weeks ago

Also impacted here following the use of KAFKA_CLIENT_KEYand KAFKA_CLIENT_CERT environnent variable. I think @matthewhughes-uw is right, using the same environment variable name for the two parameters trigger the deprecation message. Maybe time has come to remove the deprecated parameters ? :)