1. Packages
  2. Ionoscloud
  3. API Docs
  4. compute
  5. Balancer
IonosCloud v0.2.3 published on Tuesday, May 13, 2025 by ionos-cloud

ionoscloud.compute.Balancer

Explore with Pulumi AI

ionoscloud logo
IonosCloud v0.2.3 published on Tuesday, May 13, 2025 by ionos-cloud

    Manages a Load Balancer on IonosCloud.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@ionos-cloud/sdk-pulumi";
    import * as random from "@pulumi/random";
    
    const example = new ionoscloud.compute.Datacenter("example", {
        name: "Datacenter Example",
        location: "us/las",
        description: "Datacenter Description",
        secAuthProtection: false,
    });
    const exampleLan = new ionoscloud.compute.Lan("example", {
        datacenterId: example.id,
        "public": true,
        name: "Lan Example",
    });
    const serverImagePassword = new random.index.Password("server_image_password", {
        length: 16,
        special: false,
    });
    const exampleServer = new ionoscloud.compute.Server("example", {
        name: "Server Example",
        datacenterId: example.id,
        cores: 1,
        ram: 1024,
        availabilityZone: "ZONE_1",
        cpuFamily: "INTEL_XEON",
        imageName: "Ubuntu-20.04",
        imagePassword: serverImagePassword.result,
        volume: {
            name: "system",
            size: 14,
            diskType: "SSD",
        },
        nic: {
            lan: 1,
            dhcp: true,
            firewallActive: true,
        },
    });
    const exampleBalancer = new ionoscloud.compute.Balancer("example", {
        datacenterId: example.id,
        nicIds: [exampleServer.primaryNic],
        name: "Load Balancer Example",
        dhcp: true,
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    import pulumi_random as random
    
    example = ionoscloud.compute.Datacenter("example",
        name="Datacenter Example",
        location="us/las",
        description="Datacenter Description",
        sec_auth_protection=False)
    example_lan = ionoscloud.compute.Lan("example",
        datacenter_id=example.id,
        public=True,
        name="Lan Example")
    server_image_password = random.index.Password("server_image_password",
        length=16,
        special=False)
    example_server = ionoscloud.compute.Server("example",
        name="Server Example",
        datacenter_id=example.id,
        cores=1,
        ram=1024,
        availability_zone="ZONE_1",
        cpu_family="INTEL_XEON",
        image_name="Ubuntu-20.04",
        image_password=server_image_password["result"],
        volume={
            "name": "system",
            "size": 14,
            "disk_type": "SSD",
        },
        nic={
            "lan": 1,
            "dhcp": True,
            "firewall_active": True,
        })
    example_balancer = ionoscloud.compute.Balancer("example",
        datacenter_id=example.id,
        nic_ids=[example_server.primary_nic],
        name="Load Balancer Example",
        dhcp=True)
    
    package main
    
    import (
    	"github.com/ionos-cloud/pulumi-ionoscloud/sdk/go/ionoscloud/compute"
    	"github.com/pulumi/pulumi-random/sdk/go/random"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := compute.NewDatacenter(ctx, "example", &compute.DatacenterArgs{
    			Name:              pulumi.String("Datacenter Example"),
    			Location:          pulumi.String("us/las"),
    			Description:       pulumi.String("Datacenter Description"),
    			SecAuthProtection: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewLan(ctx, "example", &compute.LanArgs{
    			DatacenterId: example.ID(),
    			Public:       pulumi.Bool(true),
    			Name:         pulumi.String("Lan Example"),
    		})
    		if err != nil {
    			return err
    		}
    		serverImagePassword, err := random.NewPassword(ctx, "server_image_password", &random.PasswordArgs{
    			Length:  16,
    			Special: false,
    		})
    		if err != nil {
    			return err
    		}
    		exampleServer, err := compute.NewServer(ctx, "example", &compute.ServerArgs{
    			Name:             pulumi.String("Server Example"),
    			DatacenterId:     example.ID(),
    			Cores:            pulumi.Int(1),
    			Ram:              pulumi.Int(1024),
    			AvailabilityZone: pulumi.String("ZONE_1"),
    			CpuFamily:        pulumi.String("INTEL_XEON"),
    			ImageName:        pulumi.String("Ubuntu-20.04"),
    			ImagePassword:    serverImagePassword.Result,
    			Volume: &compute.ServerVolumeArgs{
    				Name:     pulumi.String("system"),
    				Size:     pulumi.Int(14),
    				DiskType: pulumi.String("SSD"),
    			},
    			Nic: &compute.ServerNicArgs{
    				Lan:            pulumi.Int(1),
    				Dhcp:           pulumi.Bool(true),
    				FirewallActive: pulumi.Bool(true),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewBalancer(ctx, "example", &compute.BalancerArgs{
    			DatacenterId: example.ID(),
    			NicIds: pulumi.StringArray{
    				exampleServer.PrimaryNic,
    			},
    			Name: pulumi.String("Load Balancer Example"),
    			Dhcp: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Ionoscloud.Pulumi.Ionoscloud;
    using Random = Pulumi.Random;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Ionoscloud.Compute.Datacenter("example", new()
        {
            Name = "Datacenter Example",
            Location = "us/las",
            Description = "Datacenter Description",
            SecAuthProtection = false,
        });
    
        var exampleLan = new Ionoscloud.Compute.Lan("example", new()
        {
            DatacenterId = example.Id,
            Public = true,
            Name = "Lan Example",
        });
    
        var serverImagePassword = new Random.Index.Password("server_image_password", new()
        {
            Length = 16,
            Special = false,
        });
    
        var exampleServer = new Ionoscloud.Compute.Server("example", new()
        {
            Name = "Server Example",
            DatacenterId = example.Id,
            Cores = 1,
            Ram = 1024,
            AvailabilityZone = "ZONE_1",
            CpuFamily = "INTEL_XEON",
            ImageName = "Ubuntu-20.04",
            ImagePassword = serverImagePassword.Result,
            Volume = new Ionoscloud.Compute.Inputs.ServerVolumeArgs
            {
                Name = "system",
                Size = 14,
                DiskType = "SSD",
            },
            Nic = new Ionoscloud.Compute.Inputs.ServerNicArgs
            {
                Lan = 1,
                Dhcp = true,
                FirewallActive = true,
            },
        });
    
        var exampleBalancer = new Ionoscloud.Compute.Balancer("example", new()
        {
            DatacenterId = example.Id,
            NicIds = new[]
            {
                exampleServer.PrimaryNic,
            },
            Name = "Load Balancer Example",
            Dhcp = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.compute.Datacenter;
    import com.pulumi.ionoscloud.compute.DatacenterArgs;
    import com.pulumi.ionoscloud.compute.Lan;
    import com.pulumi.ionoscloud.compute.LanArgs;
    import com.pulumi.random.password;
    import com.pulumi.random.PasswordArgs;
    import com.pulumi.ionoscloud.compute.Server;
    import com.pulumi.ionoscloud.compute.ServerArgs;
    import com.pulumi.ionoscloud.compute.inputs.ServerVolumeArgs;
    import com.pulumi.ionoscloud.compute.inputs.ServerNicArgs;
    import com.pulumi.ionoscloud.compute.Balancer;
    import com.pulumi.ionoscloud.compute.BalancerArgs;
    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 example = new Datacenter("example", DatacenterArgs.builder()
                .name("Datacenter Example")
                .location("us/las")
                .description("Datacenter Description")
                .secAuthProtection(false)
                .build());
    
            var exampleLan = new Lan("exampleLan", LanArgs.builder()
                .datacenterId(example.id())
                .public_(true)
                .name("Lan Example")
                .build());
    
            var serverImagePassword = new Password("serverImagePassword", PasswordArgs.builder()
                .length(16)
                .special(false)
                .build());
    
            var exampleServer = new Server("exampleServer", ServerArgs.builder()
                .name("Server Example")
                .datacenterId(example.id())
                .cores(1)
                .ram(1024)
                .availabilityZone("ZONE_1")
                .cpuFamily("INTEL_XEON")
                .imageName("Ubuntu-20.04")
                .imagePassword(serverImagePassword.result())
                .volume(ServerVolumeArgs.builder()
                    .name("system")
                    .size(14)
                    .diskType("SSD")
                    .build())
                .nic(ServerNicArgs.builder()
                    .lan("1")
                    .dhcp(true)
                    .firewallActive(true)
                    .build())
                .build());
    
            var exampleBalancer = new Balancer("exampleBalancer", BalancerArgs.builder()
                .datacenterId(example.id())
                .nicIds(exampleServer.primaryNic())
                .name("Load Balancer Example")
                .dhcp(true)
                .build());
    
        }
    }
    
    resources:
      example:
        type: ionoscloud:compute:Datacenter
        properties:
          name: Datacenter Example
          location: us/las
          description: Datacenter Description
          secAuthProtection: false
      exampleLan:
        type: ionoscloud:compute:Lan
        name: example
        properties:
          datacenterId: ${example.id}
          public: true
          name: Lan Example
      exampleServer:
        type: ionoscloud:compute:Server
        name: example
        properties:
          name: Server Example
          datacenterId: ${example.id}
          cores: 1
          ram: 1024
          availabilityZone: ZONE_1
          cpuFamily: INTEL_XEON
          imageName: Ubuntu-20.04
          imagePassword: ${serverImagePassword.result}
          volume:
            name: system
            size: 14
            diskType: SSD
          nic:
            lan: '1'
            dhcp: true
            firewallActive: true
      exampleBalancer:
        type: ionoscloud:compute:Balancer
        name: example
        properties:
          datacenterId: ${example.id}
          nicIds:
            - ${exampleServer.primaryNic}
          name: Load Balancer Example
          dhcp: true
      serverImagePassword:
        type: random:password
        name: server_image_password
        properties:
          length: 16
          special: false
    

    A note on nics

    When declaring NIC resources to be used with the load balancer, please make sure you use the “lifecycle meta-argument” to make sure changes to the lan attribute of the nic are ignored.

    Please see the Nic resource’s documentation for an example on how to do that.

    Create Balancer Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Balancer(name: string, args: BalancerArgs, opts?: CustomResourceOptions);
    @overload
    def Balancer(resource_name: str,
                 args: BalancerArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def Balancer(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 datacenter_id: Optional[str] = None,
                 nic_ids: Optional[Sequence[str]] = None,
                 dhcp: Optional[bool] = None,
                 ip: Optional[str] = None,
                 name: Optional[str] = None)
    func NewBalancer(ctx *Context, name string, args BalancerArgs, opts ...ResourceOption) (*Balancer, error)
    public Balancer(string name, BalancerArgs args, CustomResourceOptions? opts = null)
    public Balancer(String name, BalancerArgs args)
    public Balancer(String name, BalancerArgs args, CustomResourceOptions options)
    
    type: ionoscloud:compute:Balancer
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args BalancerArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args BalancerArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args BalancerArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BalancerArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BalancerArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var ionoscloudBalancerResource = new Ionoscloud.Compute.Balancer("ionoscloudBalancerResource", new()
    {
        DatacenterId = "string",
        NicIds = new[]
        {
            "string",
        },
        Dhcp = false,
        Ip = "string",
        Name = "string",
    });
    
    example, err := compute.NewBalancer(ctx, "ionoscloudBalancerResource", &compute.BalancerArgs{
    	DatacenterId: pulumi.String("string"),
    	NicIds: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Dhcp: pulumi.Bool(false),
    	Ip:   pulumi.String("string"),
    	Name: pulumi.String("string"),
    })
    
    var ionoscloudBalancerResource = new com.ionoscloud.pulumi.ionoscloud.compute.Balancer("ionoscloudBalancerResource", com.ionoscloud.pulumi.ionoscloud.compute.BalancerArgs.builder()
        .datacenterId("string")
        .nicIds("string")
        .dhcp(false)
        .ip("string")
        .name("string")
        .build());
    
    ionoscloud_balancer_resource = ionoscloud.compute.Balancer("ionoscloudBalancerResource",
        datacenter_id="string",
        nic_ids=["string"],
        dhcp=False,
        ip="string",
        name="string")
    
    const ionoscloudBalancerResource = new ionoscloud.compute.Balancer("ionoscloudBalancerResource", {
        datacenterId: "string",
        nicIds: ["string"],
        dhcp: false,
        ip: "string",
        name: "string",
    });
    
    type: ionoscloud:compute:Balancer
    properties:
        datacenterId: string
        dhcp: false
        ip: string
        name: string
        nicIds:
            - string
    

    Balancer Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Balancer resource accepts the following input properties:

    DatacenterId string
    [string] The ID of a Virtual Data Center.
    NicIds List<string>
    [list] A list of NIC IDs that are part of the load balancer.
    Dhcp bool
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    Ip string
    [string] IPv4 address of the load balancer.
    Name string
    [string] The name of the load balancer.
    DatacenterId string
    [string] The ID of a Virtual Data Center.
    NicIds []string
    [list] A list of NIC IDs that are part of the load balancer.
    Dhcp bool
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    Ip string
    [string] IPv4 address of the load balancer.
    Name string
    [string] The name of the load balancer.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    nicIds List<String>
    [list] A list of NIC IDs that are part of the load balancer.
    dhcp Boolean
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip String
    [string] IPv4 address of the load balancer.
    name String
    [string] The name of the load balancer.
    datacenterId string
    [string] The ID of a Virtual Data Center.
    nicIds string[]
    [list] A list of NIC IDs that are part of the load balancer.
    dhcp boolean
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip string
    [string] IPv4 address of the load balancer.
    name string
    [string] The name of the load balancer.
    datacenter_id str
    [string] The ID of a Virtual Data Center.
    nic_ids Sequence[str]
    [list] A list of NIC IDs that are part of the load balancer.
    dhcp bool
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip str
    [string] IPv4 address of the load balancer.
    name str
    [string] The name of the load balancer.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    nicIds List<String>
    [list] A list of NIC IDs that are part of the load balancer.
    dhcp Boolean
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip String
    [string] IPv4 address of the load balancer.
    name String
    [string] The name of the load balancer.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Balancer resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing Balancer Resource

    Get an existing Balancer resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: BalancerState, opts?: CustomResourceOptions): Balancer
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            datacenter_id: Optional[str] = None,
            dhcp: Optional[bool] = None,
            ip: Optional[str] = None,
            name: Optional[str] = None,
            nic_ids: Optional[Sequence[str]] = None) -> Balancer
    func GetBalancer(ctx *Context, name string, id IDInput, state *BalancerState, opts ...ResourceOption) (*Balancer, error)
    public static Balancer Get(string name, Input<string> id, BalancerState? state, CustomResourceOptions? opts = null)
    public static Balancer get(String name, Output<String> id, BalancerState state, CustomResourceOptions options)
    resources:  _:    type: ionoscloud:compute:Balancer    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    DatacenterId string
    [string] The ID of a Virtual Data Center.
    Dhcp bool
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    Ip string
    [string] IPv4 address of the load balancer.
    Name string
    [string] The name of the load balancer.
    NicIds List<string>
    [list] A list of NIC IDs that are part of the load balancer.
    DatacenterId string
    [string] The ID of a Virtual Data Center.
    Dhcp bool
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    Ip string
    [string] IPv4 address of the load balancer.
    Name string
    [string] The name of the load balancer.
    NicIds []string
    [list] A list of NIC IDs that are part of the load balancer.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    dhcp Boolean
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip String
    [string] IPv4 address of the load balancer.
    name String
    [string] The name of the load balancer.
    nicIds List<String>
    [list] A list of NIC IDs that are part of the load balancer.
    datacenterId string
    [string] The ID of a Virtual Data Center.
    dhcp boolean
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip string
    [string] IPv4 address of the load balancer.
    name string
    [string] The name of the load balancer.
    nicIds string[]
    [list] A list of NIC IDs that are part of the load balancer.
    datacenter_id str
    [string] The ID of a Virtual Data Center.
    dhcp bool
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip str
    [string] IPv4 address of the load balancer.
    name str
    [string] The name of the load balancer.
    nic_ids Sequence[str]
    [list] A list of NIC IDs that are part of the load balancer.
    datacenterId String
    [string] The ID of a Virtual Data Center.
    dhcp Boolean
    [Boolean] Indicates if the load balancer will reserve an IP using DHCP.
    ip String
    [string] IPv4 address of the load balancer.
    name String
    [string] The name of the load balancer.
    nicIds List<String>
    [list] A list of NIC IDs that are part of the load balancer.

    Import

    Resource Load Balancer can be imported using the resource id, e.g.

    $ pulumi import ionoscloud:compute/balancer:Balancer myloadbalancer datacenter uuid/loadbalancer uuid
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    ionoscloud ionos-cloud/pulumi-ionoscloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the ionoscloud Terraform Provider.
    ionoscloud logo
    IonosCloud v0.2.3 published on Tuesday, May 13, 2025 by ionos-cloud