A high-level resource for creating a Service in Consul in the Consul catalog. This is appropriate for registering external services and can be used to create services addressable by Consul that cannot be registered with a local agent.
Creating a new node with the service:
resource "consul_service" "google" {
name = "google"
node = "${consul_node.compute.name}"
port = 80
tags = ["tag0"]
}
resource "consul_node" "compute" {
name = "compute-google"
address = "www.google.com"
}
Utilizing an existing known node:
resource "consul_service" "google" {
name = "google"
node = "google"
port = 443
}
Register a health-check:
resource "consul_service" "redis" {
name = "redis"
node = "redis"
port = 6379
check {
check_id = "service:redis1"
name = "Redis health check"
status = "passing"
http = "https://www.hashicorptest.com"
tls_skip_verify = false
method = "PUT"
interval = "5s"
timeout = "1s"
deregister_critical_service_after = "30s"
header {
name = "foo"
value = ["test"]
}
header {
name = "bar"
value = ["test"]
}
}
}
name
(String) The name of the service.node
(String) The name of the node the to register the service on.address
(String) The address of the service. Defaults to the address of the node.check
(Block Set) (see below for nested schema)datacenter
(String) The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.enable_tag_override
(Boolean) Specifies to disable the anti-entropy feature for this service's tags. Defaults to false
.external
(Boolean, Deprecated)meta
(Map of String) A map of arbitrary KV metadata linked to the service instance.namespace
(String) The namespace to create the service within.partition
(String) The partition the service is associated with.port
(Number) The port of the service.service_id
(String) If the service ID is not provided, it will be defaulted to the value of the name
attribute.tags
(List of String) A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.id
(String) The ID of this resource.check
Required:
check_id
(String) An ID, unique per agent.interval
(String) The interval to wait between each health-check invocation.name
(String) The name of the health-check.timeout
(String) Specifies a timeout for outgoing connections in the case of a HTTP or TCP check.Optional:
deregister_critical_service_after
(String) The time after which the service is automatically deregistered when in the critical
state. Defaults to 30s
.header
(Block Set) The headers to send for an HTTP check. The attributes of each header is given below. (see below for nested schema)http
(String) The HTTP endpoint to call for an HTTP check.method
(String) The method to use for HTTP health-checks. Defaults to GET
.notes
(String) An opaque field meant to hold human readable text.status
(String) The initial health-check status.tcp
(String) The TCP address and port to connect to for a TCP check.tls_skip_verify
(Boolean) Whether to deactivate certificate verification for HTTP health-checks. Defaults to false
.check.header
Required:
name
(String) The name of the header.value
(List of String) The header's list of values.