elastic / terraform-provider-elasticstack

Terraform provider for Elastic Stack
https://registry.terraform.io/providers/elastic/elasticstack/latest/docs
Apache License 2.0
170 stars 92 forks source link

[Feature] Kibana authentication on resource-level `kibana_connection` #509

Open Zawadidone opened 10 months ago

Zawadidone commented 10 months ago

Is your feature request related to a problem? Please describe. I would like to use the provider to create Kibana resources (elasticstack_kibana_*) on multiple Elastic Cloud cluster. But this is not supported for Kibana resources, because this can only be configured in the provider section using static credentials for a single Kibana instance.

https://registry.terraform.io/providers/elastic/elasticstack/latest/docs

provider "elasticstack" {
  kibana {
    username  = "elastic"
    password  = "changeme"
    endpoints = ["http://localhost:5601"]
  }
}

Each elasticsearch resource supports an elasticsearch_connection block, which allows the usage of the same provider on multiple Elasticsearch instances. I would like to have the same feature for Kibana resources.

Describe the solution you'd like Add the kibana_connection block to every Kibana resource (elasticstack_kibana_*) which can be used by Terraform to connect with a Kibana instance:

resource "elasticstack_kibana_data_view" "default" {
  [...]

  kibana_connection {
    endpoints = [ec_deployment.default.kibana.https_endpoint]
    username  = ec_deployment.default.elasticsearch_username
    password  = ec_deployment.default.elasticsearch_password
  }
}
romanlytovchenko commented 10 months ago

But it is possible to configure few providers with aliases for different kibana instances, like this:

provider "elasticstack" {
  alias      = "kibana_1"
  kibana {
    username  = "elastic"
    password  = "changeme"
    endpoints = ["http://localhost:5601"]
  }
provider "elasticstack" {
  alias      = "kibana_2"
  kibana {
    username  = "elastic"
    password  = "changeme"
    endpoints = ["http://localhost:5601"]
  }
}
Zawadidone commented 10 months ago

This only supports a hardcoded provider configuration without the usage of variables. The values of the arguments username, password and endpoints are not known when writing the provider but are dependent on other resources like ec_deployment.