hashicorp / terraform-provider-consul

Terraform Consul provider
https://www.terraform.io/docs/providers/consul/
Mozilla Public License 2.0
124 stars 113 forks source link

feature request: `data "consul_agent_config_file"` #395

Open nfi-hashicorp opened 7 months ago

nfi-hashicorp commented 7 months ago

Generating a config file for a Consul agent currently means either using string templating to generate HCL or generating JSON. It would be nice if there were a data that would produce valid config HCL instead of having to resort to templating structured data with string templates, or JSON.

Similar to vault_policy_document.

It could look something like this:

data "consul_agent_config_file" "example" {
    datacenter = "east-aws"
    data_dir = "/opt/consul"
    log_level = "INFO"
    node_name = "foobar"
    server = true
    watches = [
      {
        type = "checks"
        handler = "/usr/bin/health-check-handler.sh"
      }
    ]

    telemetry {
      statsite_address = "127.0.0.1:2180"
    }
}

And then written to a file or wherever with data.consul_agent_config_file.example.hcl.

I'm easy on the names. Considering there is already a data called consul_agent_config which refers to fetching config with the API, I'm not sure what to call this to make it clear.