Skip to main content

dtcloud_lb_member (Resource)

Manages one back-end member of a pool: a machine, the port it serves on, and its share of the traffic.

One resource per member rather than the platform's batch endpoint, which replaces the whole member set in one call and would leave two resources owning the same list.

Example Usage​

# The machines on the pool's network that can be added as members.
data "dtcloud_lb_vms" "candidates" {
network_id = dtcloud_network.app.id
}

# One resource per member: each is created and deleted on its own.
resource "dtcloud_lb_member" "web" {
for_each = { for vm in data.dtcloud_lb_vms.candidates.vms : vm.name => vm }

lb_id = dtcloud_lb.public.id
pool_id = dtcloud_lb_pool.web.pool_id

name = each.key
compute_server_id = each.value.id
address = each.value.ip_address
protocol_port = 8080
weight = 1
}
note

dtcloud_lb_vms lists the machines eligible to be members on a given network, with their addresses. It is what makes a for_each member set possible without pasting ids.

Schema​

Required​

  • address (String) IP address of the member. Changing this forces a new resource to be created.
  • compute_server_id (String) ID of the VM behind this address. Changing this forces a new resource to be created.
  • lb_id (String) ID of the load balancer. Changing this forces a new resource to be created.
  • pool_id (String) ID of the pool this member belongs to. Changing this forces a new resource to be created.

Optional​

  • backup (Boolean) Whether this member only receives traffic once the others are down.
  • enabled (Boolean) Whether the member is administratively enabled.
  • monitor_address (String) Address the health monitor probes, when it differs from address.
  • monitor_port (Number) Port the health monitor probes, when it differs from protocol_port.
  • name (String) Name of the member. Write-only: it is stored by the platform but never reported back, so it cannot be imported and drift in it is invisible. See vm_name for the name the API does report.
  • protocol_port (Number) Port the member listens on. Defaults to the pool's port when omitted. Changing this forces a new resource to be created.
  • timeouts (Block, Optional) (see below for nested schema)
  • weight (Number) Relative share of traffic this member receives.

Read-Only​

  • id (String) The ID of this resource.
  • member_id (String) ID of the member on its own, without the load balancer and pool prefixes.
  • state (String) Operating state reported by the platform.
  • vm_name (String) Name of the VM behind this member, as reported by the API.

Nested Schema for timeouts​

Optional:

  • create (String)
  • delete (String)
  • update (String)

Behaviour worth knowing​

  • The member list reports only id, name, state and address. weight, the monitor overrides and backup are write-only: they are sent on create and update but never read back, so drift in them is invisible.
  • name is write-only too, for a subtler reason. The platform stores it, but the list reports the name of the machine behind the member instead. Reading that back into name would give every member a permanent diff, so the reported value is kept under vm_name, where it is true.
  • protocol_port is fixed at creation. Import a member only when its port matches the pool's, since nothing reports it and an imported member whose configuration names one will be replaced.
  • A machine can hold several addresses on one network. address names which one receives traffic.

Timeouts​

create, update and delete each default to 15 minutes.

Import​

# <load-balancer-id>:<pool-id>:<member-id>
terraform import dtcloud_lb_member.web 3d372446-4c75-4327-9511-98442456162f:5b2a9c31-7e04-4d88-9c6e-44a2f1d0e7b3:c40d8e19-1b73-4f2a-95cc-0a6b7e3d1c88

compute_server_id is recovered indirectly: the candidate lookup lists every machine with a port on the network along with its addresses, and the member's address is known. That costs two extra calls and happens on import only.