consul_service

consul_service provides details about a specific Consul service in a given datacenter. The results include a list of nodes advertising the specified service, the node's IP address, port number, node ID, etc. By specifying a different datacenter in the query_options it is possible to retrieve a list of services from a different WAN-attached Consul datacenter.

This data source is different from the consul_services (plural) data source, which provides a summary of the current Consul services.

Example Usage

data "consul_service" "read-consul-dc1" {
    name = "consul"
    # Optional parameter: implicitly uses the current datacenter of the agent
    datacenter = "dc1"
}

# Set the description to a whitespace delimited list of the node names
resource "example_resource" "app" {
  description = "${join(" ", data.consul_service.nodes)}"

  # ...
}

Argument Reference

The following arguments are supported:

The query_options block supports the following:

Attributes Reference

The following attributes are exported:

The following is a list of the per-node service attributes: