# 

# exoscale_nlb_service (Resource)

Manage Exoscale [Network Load Balancer (NLB)](https://community.exoscale.com/product/networking/nlb/) Services.

## Example Usage

```terraform
resource "exoscale_nlb" "my_nlb" {
  zone = "ch-gva-2"
  name = "my-nlb"
}

resource "exoscale_nlb_service" "my_nlb_service" {
  nlb_id = exoscale_nlb.my_nlb.id
  zone   = exoscale_nlb.my_nlb.zone
  name   = "my-nlb-service"

  instance_pool_id = exoscale_instance_pool.my_instance_pool.id
  protocol         = "tcp"
  port             = 443
  target_port      = 8443
  strategy         = "round-robin"

  healthcheck {
    mode     = "https"
    port     = 8443
    uri      = "/healthz"
    tls_sni  = "example.net"
    interval = 5
    timeout  = 3
    retries  = 1
  }
}
```

Please refer to the [examples](https://github.com/exoscale/terraform-provider-exoscale/tree/master/examples/)
directory for complete configuration examples.

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `healthcheck` (Block Set, Min: 1) The service health checking configuration. (see [below for nested schema](#nestedblock--healthcheck))
- `instance_pool_id` (String) ❗ The [exoscale_instance_pool]({{< ref "./instance_pool.md" >}}) (ID) to forward traffic to.
- `name` (String) The NLB service name.
- `nlb_id` (String) ❗ The parent [exoscale_nlb]({{< ref "./nlb.md" >}}) ID.
- `port` (Number) The healthcheck port.
- `target_port` (Number) The (TCP/UDP) port to forward traffic to (on target instance pool members).
- `zone` (String) ❗ The Exoscale [Zone](https://www.exoscale.com/datacenters/) name.

### Optional

- `description` (String) A free-form text describing the NLB service.
- `protocol` (String) The protocol (`tcp`|`udp`; default: `tcp`).
- `strategy` (String) The strategy (`round-robin`|`source-hash`; default: `round-robin`).
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `id` (String) The ID of this resource.
- `state` (String)

<a id="nestedblock--healthcheck"></a>
### Nested Schema for `healthcheck`

Required:

- `port` (Number) The NLB service (TCP/UDP) port.

Optional:

- `interval` (Number) The healthcheck interval in seconds (default: `10`).
- `mode` (String) The healthcheck mode (`tcp`|`http`|`https`; default: `tcp`).
- `retries` (Number) The healthcheck retries (default: `1`).
- `timeout` (Number) The healthcheck timeout (seconds; default: `5`).
- `tls_sni` (String) The healthcheck TLS SNI server name (only if `mode` is `https`).
- `uri` (String) The healthcheck URI (must be set only if `mode` is `http(s)`).


<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `delete` (String)
- `read` (String)
- `update` (String)

-> The symbol ❗ in an attribute indicates that modifying it, will force the creation of a new resource.

## Import

```shell
# An existing NLB service may be imported by `<nlb-ID>/<service-ID>@<zone>`:

terraform import \
  exoscale_nlb_service.my_nlb_service \
  f81d4fae-7dec-11d0-a765-00a0c91e6bf6/9ecc6b8b-73d4-4211-8ced-f7f29bb79524@ch-gva-2
```

