terraform-provider-restapi icon indicating copy to clipboard operation
terraform-provider-restapi copied to clipboard

Allow empty uri in provider configuration

Open mraszplewicz opened this issue 6 years ago • 5 comments

Hi,

We are using restapi provider to configure elasticsearch, which is created in the same terraform apply. It is not possible to set the uri parameter to the output of newly created resource (https://github.com/hashicorp/terraform/issues/2430). It will be great to have a possibility to leave provider's uri parameter empty.

For now we are using "clever" workaround:

provider "restapi" {
  uri = "https:"
}

And in the resource:

resource "restapi_object" "elasticsearch_template_others" {
  path        = "//${aws_elasticsearch_domain.es.endpoint}/_template"

  object_id   = "template_2"
  create_path = "//${aws_elasticsearch_domain.es.endpoint}/_template/{id}"

  data        = <<EOF
{
    "index_patterns": [
        "*"
    ],
    "settings": {
        "number_of_shards": "1",
        "number_of_replicas": "1"
    }
}
EOF
}

mraszplewicz avatar Dec 12 '18 11:12 mraszplewicz

+1

@mraszplewicz thanks for workarround.

GuiuMateu avatar Jan 10 '19 14:01 GuiuMateu

This should be fixed in terraform 0.12 beta just released.

TMaYaD avatar Mar 01 '19 23:03 TMaYaD

AFAIK still an issue in terraform 0.15: https://github.com/hashicorp/terraform/issues/2430

A provider is initialised in the beginning prior any resources has been created. The consequence is that the uri can't be set to a dynamic value, e.g a service's URI which is about to be deployed.

+1 on the solution by @mraszplewicz, to be able to have an empty uri field in the provider.

RickardCardell avatar Mar 30 '21 12:03 RickardCardell

Experiencing the same issue with where the api we want to leverage is created by the same terraform script.

Using terraform 0.15.3 . The workaround only worked for me when it was the default provider

Could a lazy init or something similar be done?

emmaroberts-nbs avatar Jun 29 '21 13:06 emmaroberts-nbs

+1

wallacepf avatar Jul 06 '22 13:07 wallacepf