fbpx

Elastigroup

This post demonstrates how to create a Health Check Service using the Spotinst Terraform plugin.

This post assumes that you already have a Spotinst account and went through Spotinst Terraform Installation & Configuration.

Spotinst Health Check Service Resource

The Spotinst Health Check service will act as a proxy between Spotinst hosts and your
EC2 private instances in your VPC.
Spotinst will trigger the proxy service on each check. The proxy will communicate with your private instances in the VPC and will send the results to Spotinst.
When an instance is marked as unhealthy, and the Elastigroup Health Check type is set to HCS, Spotinst will replace it with a new instance according to the Elastigroup config.

resource "spotinst_healthcheck" "foo" {
  name        = "hc-foo"
  resource_id = "sig-foo"
  check {
    protocol = "http"
    endpoint = "http://endpoint.com"
    port     = 1337
    interval = 10
    timeout  = 10
  }
  threshold {
    healthy   = 1
    unhealthy = 1
  }
  proxy {
    addr = "http://proxy.com"
    port = 80
  }
}

name – string – (Required) A logical name for the health check

resource_id – string – (Required) Spotinst Resource id (Elastigroup ID)

check – object – (Required) configuration for the health check

protocol – string – (Required) The protocol to use to connect to the instance. Valid values: http https

endpoint – string – (Required) The URL destination for the request

port – integer – (Required) The port to use to connect with the instance

timeout – integer – (Required) The amount of time (in seconds) to wait when receiving a response from the health check

interval – integer – (Required) The amount of time (in seconds) between each health check. Minimum value is 10

threshold – (Required) Threshold settings for the health check

healthy – integer – (Required) The number of consecutive successful health checks that must occur before declaring an instance healthy

unhealthy – integer – (Required) The number of consecutive failed health checks that must occur before declaring an instance unhealthy

proxy – (Required) The Proxy settings

addr – string – (Required) The URL of the proxy

port – string – (Required) The proxy port