Load Balancer Args
Provides a DigitalOcean Load Balancer resource. This can be used to create, modify, and delete Load Balancers.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const web = new digitalocean.Droplet("web", {
name: "web-1",
size: digitalocean.DropletSlug.DropletS1VCPU1GB,
image: "ubuntu-18-04-x64",
region: digitalocean.Region.NYC3,
});
const _public = new digitalocean.LoadBalancer("public", {
name: "loadbalancer-1",
region: digitalocean.Region.NYC3,
forwardingRules: [{
entryPort: 80,
entryProtocol: "http",
targetPort: 80,
targetProtocol: "http",
}],
healthcheck: {
port: 22,
protocol: "tcp",
},
dropletIds: [web.id],
});
import pulumi
import pulumi_digitalocean as digitalocean
web = digitalocean.Droplet("web",
name="web-1",
size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
image="ubuntu-18-04-x64",
region=digitalocean.Region.NYC3)
public = digitalocean.LoadBalancer("public",
name="loadbalancer-1",
region=digitalocean.Region.NYC3,
forwarding_rules=[{
"entry_port": 80,
"entry_protocol": "http",
"target_port": 80,
"target_protocol": "http",
}],
healthcheck={
"port": 22,
"protocol": "tcp",
},
droplet_ids=[web.id])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var web = new DigitalOcean.Droplet("web", new()
{
Name = "web-1",
Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
Image = "ubuntu-18-04-x64",
Region = DigitalOcean.Region.NYC3,
});
var @public = new DigitalOcean.LoadBalancer("public", new()
{
Name = "loadbalancer-1",
Region = DigitalOcean.Region.NYC3,
ForwardingRules = new[]
{
new DigitalOcean.Inputs.LoadBalancerForwardingRuleArgs
{
EntryPort = 80,
EntryProtocol = "http",
TargetPort = 80,
TargetProtocol = "http",
},
},
Healthcheck = new DigitalOcean.Inputs.LoadBalancerHealthcheckArgs
{
Port = 22,
Protocol = "tcp",
},
DropletIds = new[]
{
web.Id,
},
});
});
package main
import (
"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
web, err := digitalocean.NewDroplet(ctx, "web", &digitalocean.DropletArgs{
Name: pulumi.String("web-1"),
Size: pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
Image: pulumi.String("ubuntu-18-04-x64"),
Region: pulumi.String(digitalocean.RegionNYC3),
})
if err != nil {
return err
}
_, err = digitalocean.NewLoadBalancer(ctx, "public", &digitalocean.LoadBalancerArgs{
Name: pulumi.String("loadbalancer-1"),
Region: pulumi.String(digitalocean.RegionNYC3),
ForwardingRules: digitalocean.LoadBalancerForwardingRuleArray{
&digitalocean.LoadBalancerForwardingRuleArgs{
EntryPort: pulumi.Int(80),
EntryProtocol: pulumi.String("http"),
TargetPort: pulumi.Int(80),
TargetProtocol: pulumi.String("http"),
},
},
Healthcheck: &digitalocean.LoadBalancerHealthcheckArgs{
Port: pulumi.Int(22),
Protocol: pulumi.String("tcp"),
},
DropletIds: pulumi.IntArray{
web.ID(),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.Droplet;
import com.pulumi.digitalocean.DropletArgs;
import com.pulumi.digitalocean.LoadBalancer;
import com.pulumi.digitalocean.LoadBalancerArgs;
import com.pulumi.digitalocean.inputs.LoadBalancerForwardingRuleArgs;
import com.pulumi.digitalocean.inputs.LoadBalancerHealthcheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var web = new Droplet("web", DropletArgs.builder()
.name("web-1")
.size("s-1vcpu-1gb")
.image("ubuntu-18-04-x64")
.region("nyc3")
.build());
var public_ = new LoadBalancer("public", LoadBalancerArgs.builder()
.name("loadbalancer-1")
.region("nyc3")
.forwardingRules(LoadBalancerForwardingRuleArgs.builder()
.entryPort(80)
.entryProtocol("http")
.targetPort(80)
.targetProtocol("http")
.build())
.healthcheck(LoadBalancerHealthcheckArgs.builder()
.port(22)
.protocol("tcp")
.build())
.dropletIds(web.id())
.build());
}
}
resources:
web:
type: digitalocean:Droplet
properties:
name: web-1
size: s-1vcpu-1gb
image: ubuntu-18-04-x64
region: nyc3
public:
type: digitalocean:LoadBalancer
properties:
name: loadbalancer-1
region: nyc3
forwardingRules:
- entryPort: 80
entryProtocol: http
targetPort: 80
targetProtocol: http
healthcheck:
port: 22
protocol: tcp
dropletIds:
- ${web.id}
When managing certificates attached to the load balancer, make sure to add the create_before_destroy
lifecycle property in order to ensure the certificate is correctly updated when changed. The order of operations will then be: Create new certificate
Update loadbalancer with new certificate
->Delete old certificate
. When doing so, you must also change the name of the certificate, as there cannot be multiple certificates with the same name in an account.
Import
Load Balancers can be imported using the id
, e.g.
$ pulumi import digitalocean:index/loadBalancer:LoadBalancer myloadbalancer 4de7ac8b-495b-4884-9a69-1050c6793cd6
Constructors
Properties
A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer. Default value is false
.
A list of domains
required to ingress traffic to a Global Load Balancer. The domains
block is documented below.
A list of the IDs of each droplet to be attached to the Load Balancer.
The name of a Droplet tag corresponding to Droplets to be assigned to the Load Balancer.
A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. Default value is false
.
A boolean value indicating whether PROXY Protocol should be used to pass information from connecting client requests to the backend service. Default value is false
.
A block containing rules for allowing/denying traffic to the Load Balancer. The firewall
block is documented below. Only 1 firewall is allowed.
A list of forwarding_rule
to be assigned to the Load Balancer. The forwarding_rule
block is documented below.
A block containing glb_settings
required to define target rules for a Global Load Balancer. The glb_settings
block is documented below.
A healthcheck
block to be assigned to the Load Balancer. The healthcheck
block is documented below. Only 1 healthcheck is allowed.
Specifies the idle timeout for HTTPS connections on the load balancer in seconds.
The network stack determines the allocation of ipv4/ipv6 addresses to the load balancer. It must be either of IPV4
or DUALSTACK
. Defaults to IPV4
.
A boolean value indicating whether HTTP requests to the Load Balancer on port 80 will be redirected to HTTPS on port 443. Default value is false
.
A sticky_sessions
block to be assigned to the Load Balancer. The sticky_sessions
block is documented below. Only 1 sticky_sessions block is allowed.
A list of Load Balancer IDs to be attached behind a Global Load Balancer.
The tls cipher policy controls the cipher suites to be used by the load balancer. It must be either of DEFAULT
or STRONG
. Defaults to DEFAULT
.