consul_service (Resource)

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.

Example Usage

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"]
    }
  }
}

Schema

Required

Optional

Read-Only

Nested Schema for check

Required:

Optional:

Nested Schema for check.header

Required: