github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/consul/d/service.html.markdown (about) 1 --- 2 layout: "consul" 3 page_title: "Consul: consul_catalog_service" 4 sidebar_current: "docs-consul-data-source-catalog-service" 5 description: |- 6 Provides details about a specific Consul service 7 --- 8 9 # consul_catalog_service 10 11 `consul_catalog_service` provides details about a specific Consul service in a 12 given datacenter. The results include a list of nodes advertising the specified 13 service, the node's IP address, port number, node ID, etc. By specifying a 14 different datacenter in the `query_options` it is possible to retrieve a list of 15 services from a different WAN-attached Consul datacenter. 16 17 This data source is different from the `consul_catalog_services` (plural) data 18 source, which provides a summary of the current Consul services. 19 20 ## Example Usage 21 22 ```hcl 23 data "consul_catalog_service" "read-consul-dc1" { 24 query_options { 25 # Optional parameter: implicitly uses the current datacenter of the agent 26 datacenter = "dc1" 27 } 28 29 name = "consul" 30 } 31 32 # Set the description to a whitespace delimited list of the node names 33 resource "example_resource" "app" { 34 description = "${join(" ", data.consul_catalog_service.nodes)}" 35 36 # ... 37 } 38 ``` 39 40 ## Argument Reference 41 42 The following arguments are supported: 43 44 * `datacenter` - (Optional) The Consul datacenter to query. Defaults to the 45 same value found in `query_options` parameter specified below, or if that is 46 empty, the `datacenter` value found in the Consul agent that this provider is 47 configured to talk to. 48 49 * `name` - (Required) The service name to select. 50 51 * `query_options` - (Optional) See below. 52 53 * `tag` - (Optional) A single tag that can be used to filter the list of nodes 54 to return based on a single matching tag.. 55 56 The `query_options` block supports the following: 57 58 * `allow_stale` - (Optional) When `true`, the default, allow responses from 59 Consul servers that are followers. 60 61 * `require_consistent` - (Optional) When `true` force the client to perform a 62 read on at least quorum servers and verify the result is the same. Defaults 63 to `false`. 64 65 * `token` - (Optional) Specify the Consul ACL token to use when performing the 66 request. This defaults to the same API token configured by the `consul` 67 provider but may be overriden if necessary. 68 69 * `wait_index` - (Optional) Index number used to enable blocking quereis. 70 71 * `wait_time` - (Optional) Max time the client should wait for a blocking query 72 to return. 73 74 ## Attributes Reference 75 76 The following attributes are exported: 77 78 * `datacenter` - The datacenter the keys are being read from to. 79 * `name` - The name of the service 80 * `tag` - The name of the tag used to filter the list of nodes in `service`. 81 * `service` - A list of nodes and details about each endpoint advertising a 82 service. Each element in the list is a map of attributes that correspond to 83 each individual node. The list of per-node attributes is detailed below. 84 85 The following is a list of the per-node `service` attributes: 86 87 * [`create_index`](https://www.consul.io/docs/agent/http/catalog.html#CreateIndex) - 88 The index entry at which point this entry was added to the catalog. 89 * [`modify_index`](https://www.consul.io/docs/agent/http/catalog.html#ModifyIndex) - 90 The index entry at which point this entry was modified in the catalog. 91 * [`node_address`](https://www.consul.io/docs/agent/http/catalog.html#Address) - 92 The address of the Consul node advertising the service. 93 * `node_id` - The Node ID of the Consul agent advertising the service. 94 * [`node_meta`](https://www.consul.io/docs/agent/http/catalog.html#Meta) - Node 95 meta data tag information, if any. 96 * [`node_name`](https://www.consul.io/docs/agent/http/catalog.html#Node) - The 97 name of the Consul node. 98 * [`address`](https://www.consul.io/docs/agent/http/catalog.html#ServiceAddress) - 99 The IP address of the service. If the `ServiceAddress` in the Consul catalog 100 is empty, this value is automatically populated with the `node_address` (the 101 `Address` in the Consul Catalog). 102 * [`enable_tag_override`](https://www.consul.io/docs/agent/http/catalog.html#ServiceEnableTagOverride) - 103 Whether service tags can be overridden on this service. 104 * [`id`](https://www.consul.io/docs/agent/http/catalog.html#ServiceID) - A 105 unique service instance identifier. 106 * [`name`](https://www.consul.io/docs/agent/http/catalog.html#ServiceName) - The 107 name of the service. 108 * [`port`](https://www.consul.io/docs/agent/http/catalog.html#ServicePort) - 109 Port number of the service. 110 * [`tagged_addresses`](https://www.consul.io/docs/agent/http/catalog.html#TaggedAddresses) - 111 List of explicit LAN and WAN IP addresses for the agent. 112 * [`tags`](https://www.consul.io/docs/agent/http/catalog.html#ServiceTags) - 113 List of tags for the service.