load_balancer
Generated on 17 Jun 2025
from digitalocean.cloud
version
v1.2.1
Synopsis
Create or delete load balancers. DigitalOcean Load Balancers provide a way to distribute traffic across multiple Droplets. View the API documentation at https://docs.digitalocean.com/reference/api/api-reference/#tag/Load-Balancers.
Requirements
- pydo >= 0.1.3
- azure-core >= 1.26.1
Parameters
Parameter | Choices / Default | Description |
---|---|---|
client_override_options dict |
Client override options (developer use). For example, can be used to override the DigitalOcean API endpoint for an internal test suite. If provided, these options will knock out existing options. | |
disable_lets_encrypt_dns_records bool |
A boolean value indicating whether to disable automatic DNS record creation for Let’s Encrypt certificates that are added to the load balancer. | |
droplet_ids list / elements=int |
An array containing the IDs of the Droplets assigned to the load balancer. | |
enable_backend_keepalive bool |
A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. | |
enable_proxy_protocol bool |
A boolean value indicating whether PROXY Protocol is in use. | |
firewall dict |
An object specifying allow and deny rules to control traffic to the load balancer. | |
forwarding_rules list / elements=dict |
An array of objects specifying the forwarding rules for a load balancer. | |
health_checks dict |
An object specifying health check settings for the load balancer. | |
http_idle_timeout_seconds int |
Default: 60 |
An integer value which configures the idle timeout for HTTP requests to the target droplets. |
module_override_options dict |
Module override options (developer use). Can be used to override module options to support experimental or future options. If provided, these options will knock out existing options. | |
name str |
A human-readable name for a load balancer instance. | |
project_id str |
The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user’s default project. If an invalid project ID is provided, the load balancer will not be created. | |
redirect_http_to_https bool |
A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443. | |
region str / required |
The slug identifier for the region where the resource will initially be available. | |
size str |
Choices:
|
Deprecated. This field has been replaced by the size_unit field for all regions except in AMS2, NYC2, and SFO1. Each available load balancer size now equates to the load balancer having a set number of nodes. lb-small = 1 node, lb-medium = 3 nodes, lb-large = 6 nodes. |
size_unit int |
Default: 1 |
How many nodes the load balancer contains. Each additional node increases the load balancer’s ability to manage more connections. Load balancers can be scaled up or down, and you can change the number of nodes after creation up to once per hour. This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use the size field to scale load balancers that reside in these regions. |
state str |
Choices:
|
State of the resource, present to create, absent to destroy. |
sticky_sessions dict |
An object specifying sticky sessions settings for the load balancer. | |
timeout int |
Default: 300 |
Polling timeout in seconds. |
token str |
DigitalOcean API token. There are several environment variables which can be used to provide this value. DIGITALOCEAN_ACCESS_TOKEN , DIGITALOCEAN_TOKEN , DO_API_TOKEN , DO_API_KEY , DO_OAUTH_TOKEN and OAUTH_TOKEN |
|
vpc_uuid str |
A string specifying the UUID of the VPC to which the load balancer is assigned. |
Examples
- name: Create load balancer
digitalocean.cloud.load_balancer:
token: "{{ token }}"
state: present
name: example-lb1
region: nyc3
forwarding_rules:
- entry_protocol: http
entry_port: 80
target_protocol: http
target_port: 80
- entry_protocol: https
entry_port: 443
target_protocol: https
target_port: 443
tls_passthrough: true
droplet_ids:
- 11223344
disable_lets_encrypt_dns_records: true
http_idle_timeout_seconds: 60
firewall:
deny:
- cidr:1.2.0.0/16
- ip:2.3.4.5
allow:
- ip:1.2.3.4
- cidr:2.3.4.0/24
Return Values
Key | Returned | Description |
---|---|---|
error dict |
failure | DigitalOcean API error. Sample:
|
load_balancer dict |
always | Load balancer information. |
msg str |
always | Droplet result information. Sample:
|