2016-03-27 06:12:38 +02:00
---
layout: "consul"
page_title: "Consul: consul_service"
sidebar_current: "docs-consul-resource-service"
description: |-
2016-11-08 15:43:00 +01:00
A high-level resource for creating a Service in Consul. Since Consul requires clients to register services with either the catalog or an agent, `consul_service` may register with either the catalog or an agent, depending on the configuration of `consul_service` . For now, `consul_service` always registers services with the agent running at the address defined in the `consul` resource. Health checks are not currently supported.
2016-03-27 06:12:38 +02:00
---
2017-04-10 18:19:36 +02:00
# consul_service
2016-03-27 06:12:38 +02:00
2016-11-08 15:43:00 +01:00
A high-level resource for creating a Service in Consul. Currently,
defining health checks for a service is not supported.
2016-03-27 06:12:38 +02:00
## Example Usage
2017-04-10 18:19:36 +02:00
```hcl
2016-03-27 06:12:38 +02:00
resource "consul_service" "google" {
2017-02-18 23:48:50 +01:00
address = "www.google.com"
name = "google"
port = 80
tags = ["tag0", "tag1"]
2016-03-27 06:12:38 +02:00
}
```
## Argument Reference
The following arguments are supported:
2016-11-08 15:43:00 +01:00
* `service_id` - (Optional, string) The ID of the service, defaults to the value of `name`
if not supplied.
2016-10-26 14:07:00 +02:00
* `address` - (Optional, string) The address of the service. Defaults to the
2016-03-27 06:12:38 +02:00
address of the agent.
2016-10-26 14:07:00 +02:00
* `name` - (Required, string) The name of the service.
2016-03-27 06:12:38 +02:00
2016-10-26 14:07:00 +02:00
* `port` - (Optional, int) The port of the service.
2016-03-27 06:12:38 +02:00
2016-10-26 14:07:00 +02:00
* `tags` - (Optional, set of strings) A list of values that are opaque to Consul,
2016-03-27 06:12:38 +02:00
but can be used to distinguish between services or nodes.
2017-02-18 23:48:50 +01:00
2016-03-27 06:12:38 +02:00
## Attributes Reference
The following attributes are exported:
2016-10-26 14:07:00 +02:00
* `service_id` - The id of the service, defaults to the value of `name` .
2016-03-27 06:12:38 +02:00
* `address` - The address of the service.
* `name` - The name of the service.
* `port` - The port of the service.
* `tags` - The tags of the service.