phillbaker / terraform-provider-elasticsearch

An elasticsearch provider for terraform
https://registry.terraform.io/providers/phillbaker/elasticsearch
Mozilla Public License 2.0
303 stars 133 forks source link

Print `url` in debug / error logs #361

Open synfinatic opened 8 months ago

synfinatic commented 8 months ago

So due to a bug in my code, I effectively had my provider block defined as:

provider "elasticsearch" {
   url = ""
  healthcheck = false
}

This fails for obvious reasons. However, my bug was non-obvious and the log messages with TF_LOG=debug TF_ACC=1 were not helpful. The closest seems to be:

2023-11-08T08:44:43.108-0800 [INFO]  provider.terraform-provider-elasticsearch_v2.0.7: 2023/11/08 08:44:43 [INFO] couldn't create client: *errors.withStack, no active connection found: no Elasticsearch node available, *errors.withMessage: timestamp=2023-11-08T08:44:43.107-0800
2023-11-08T08:44:43.108-0800 [ERROR] vertex "elasticsearch_opensearch_role.event-trace" error: HEAD healthcheck failed: This is usually due to network or permission issues. The underlying error isn't accessible, please debug by disabling healthchecks.
2023-11-08T08:44:43.108-0800 [ERROR] vertex "elasticsearch_opensearch_role.event-trace (expand)" error: HEAD healthcheck failed: This is usually due to network or permission issues. The underlying error isn't accessible, please debug by disabling healthchecks.

Disabling healthchecks does not improve the message to indicate what the problem might be (also, it's confusing that this is still printed when healthcheck = false). Would of saved me a lot of time if the value of the url was contained somewhere in the log output.