phillbaker / terraform-provider-elasticsearch

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

Return Errors from AWS HTTP Client #316

Closed pmarques closed 2 years ago

pmarques commented 2 years ago

Description

This should fix #251 by returning the awsHttpClient errors from the provider to terraform.

Details

This should prevent errors to be suppressed and instead of

╷
│ Error: Plugin did not respond
│ 
│   with elasticsearch_opensearch_role. test-role,
│   on test.tf line 1, in resource "elasticsearch_opensearch_role" " test-role":
│    1: resource "elasticsearch_opensearch_role" " test-role" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

You should now get

│ Error: RequestError: send request failed
│ caused by: Post "https://sts.my-cluster.amazonaws.com/": dial tcp: lookup [sts.my-cluster.amazonaws.com](http://sts.my-cluster.amazonaws.com/): no such host
│ 
│   with elasticsearch_opensearch_role. test-role,
│   on [test.tf](http://test.tf/) line 1, in resource "elasticsearch_opensearch_role" "test-role":
│    1: resource "elasticsearch_opensearch_role" "test-role" {
│ 
╵

For full context, there is a long explanation https://github.com/phillbaker/terraform-provider-elasticsearch/issues/251#issuecomment-1262618439.


Note: The provider will still suppress some errors, for instance if you use aws_assume_role_arn and the Assume role fails you still get the same error:

╷
│ Error: Plugin did not respond
│ 
│   with elasticsearch_opensearch_role. test-role,
│   on test.tf line 1, in resource "elasticsearch_opensearch_role" " test-role":
│    1: resource "elasticsearch_opensearch_role" " test-role" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

To fix this another change will be required and I have some branch with some changes already

pmarques commented 2 years ago

Force pushed to add a verified commit :)