terraform-provider-kafka
terraform-provider-kafka copied to clipboard
Getting DEPRECATED messages when using environment variables for provider
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 ?
What's strange - if I deploy kafka_acls resources - I don't get those warning but if I deploy topics - I do.
Looks like this is happening because both old and new config parameters are mapped to the same environment variables
Specifically:
ca_cert_fileis deprecated and reads from theKAFKA_CA_CERTenv var- Per the deprecation we should use
ca_certinstead, but this also reads fromKAFKA_CA_CERT
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:
- the env var
KAFKA_CLIENT_KEYwhich is shared betweenclient_keyand the deprecatedclient_key_file, and - the env var
KAFKA_CLIENT_CERTwhich is shared betweenclient_certand the deprecatedclient_cert_file