1. Packages
  2. Linode Provider
  3. API Docs
  4. InstanceSharedIps
Linode v4.30.1 published on Thursday, Nov 21, 2024 by Pulumi

linode.InstanceSharedIps

Explore with Pulumi AI

linode logo
Linode v4.30.1 published on Thursday, Nov 21, 2024 by Pulumi

    Manages IPs shared to a Linode instance. For more information, see the Linode APIv4 docs.

    Beta Notice IPv6 sharing is currently available through early access. To use early access resources, the api_version provider argument must be set to v4beta. To learn more, see the early access documentation.

    Notice This resource should only be defined once per-instance and should not be used alongside the shared_ipv4 field in linode.Instance.

    Example Usage

    Share in IPv4 address between two instances:

    import * as pulumi from "@pulumi/pulumi";
    import * as linode from "@pulumi/linode";
    
    // Create a single primary node
    const primaryInstance = new linode.Instance("primary", {
        label: "node-primary",
        type: "g6-nanode-1",
        region: "eu-central",
    });
    // Allocate an IP under the primary node
    const primary = new linode.InstanceIp("primary", {linodeId: primaryInstance.id});
    // Create a secondary node
    const secondary = new linode.Instance("secondary", {
        label: "node-secondary",
        type: "g6-nanode-1",
        region: "eu-central",
    });
    // Share the IP with the secondary node
    const share_primary = new linode.InstanceSharedIps("share-primary", {
        linodeId: secondary.id,
        addresses: [primary.address],
    });
    
    import pulumi
    import pulumi_linode as linode
    
    # Create a single primary node
    primary_instance = linode.Instance("primary",
        label="node-primary",
        type="g6-nanode-1",
        region="eu-central")
    # Allocate an IP under the primary node
    primary = linode.InstanceIp("primary", linode_id=primary_instance.id)
    # Create a secondary node
    secondary = linode.Instance("secondary",
        label="node-secondary",
        type="g6-nanode-1",
        region="eu-central")
    # Share the IP with the secondary node
    share_primary = linode.InstanceSharedIps("share-primary",
        linode_id=secondary.id,
        addresses=[primary.address])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-linode/sdk/v4/go/linode"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create a single primary node
    		primaryInstance, err := linode.NewInstance(ctx, "primary", &linode.InstanceArgs{
    			Label:  pulumi.String("node-primary"),
    			Type:   pulumi.String("g6-nanode-1"),
    			Region: pulumi.String("eu-central"),
    		})
    		if err != nil {
    			return err
    		}
    		// Allocate an IP under the primary node
    		primary, err := linode.NewInstanceIp(ctx, "primary", &linode.InstanceIpArgs{
    			LinodeId: primaryInstance.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		// Create a secondary node
    		secondary, err := linode.NewInstance(ctx, "secondary", &linode.InstanceArgs{
    			Label:  pulumi.String("node-secondary"),
    			Type:   pulumi.String("g6-nanode-1"),
    			Region: pulumi.String("eu-central"),
    		})
    		if err != nil {
    			return err
    		}
    		// Share the IP with the secondary node
    		_, err = linode.NewInstanceSharedIps(ctx, "share-primary", &linode.InstanceSharedIpsArgs{
    			LinodeId: secondary.ID(),
    			Addresses: pulumi.StringArray{
    				primary.Address,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Linode = Pulumi.Linode;
    
    return await Deployment.RunAsync(() => 
    {
        // Create a single primary node
        var primaryInstance = new Linode.Instance("primary", new()
        {
            Label = "node-primary",
            Type = "g6-nanode-1",
            Region = "eu-central",
        });
    
        // Allocate an IP under the primary node
        var primary = new Linode.InstanceIp("primary", new()
        {
            LinodeId = primaryInstance.Id,
        });
    
        // Create a secondary node
        var secondary = new Linode.Instance("secondary", new()
        {
            Label = "node-secondary",
            Type = "g6-nanode-1",
            Region = "eu-central",
        });
    
        // Share the IP with the secondary node
        var share_primary = new Linode.InstanceSharedIps("share-primary", new()
        {
            LinodeId = secondary.Id,
            Addresses = new[]
            {
                primary.Address,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.linode.Instance;
    import com.pulumi.linode.InstanceArgs;
    import com.pulumi.linode.InstanceIp;
    import com.pulumi.linode.InstanceIpArgs;
    import com.pulumi.linode.InstanceSharedIps;
    import com.pulumi.linode.InstanceSharedIpsArgs;
    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) {
            // Create a single primary node
            var primaryInstance = new Instance("primaryInstance", InstanceArgs.builder()
                .label("node-primary")
                .type("g6-nanode-1")
                .region("eu-central")
                .build());
    
            // Allocate an IP under the primary node
            var primary = new InstanceIp("primary", InstanceIpArgs.builder()
                .linodeId(primaryInstance.id())
                .build());
    
            // Create a secondary node
            var secondary = new Instance("secondary", InstanceArgs.builder()
                .label("node-secondary")
                .type("g6-nanode-1")
                .region("eu-central")
                .build());
    
            // Share the IP with the secondary node
            var share_primary = new InstanceSharedIps("share-primary", InstanceSharedIpsArgs.builder()
                .linodeId(secondary.id())
                .addresses(primary.address())
                .build());
    
        }
    }
    
    resources:
      # Share the IP with the secondary node
      share-primary:
        type: linode:InstanceSharedIps
        properties:
          linodeId: ${secondary.id}
          addresses:
            - ${primary.address}
      # Allocate an IP under the primary node
      primary:
        type: linode:InstanceIp
        properties:
          linodeId: ${primaryInstance.id}
      # Create a single primary node
      primaryInstance:
        type: linode:Instance
        name: primary
        properties:
          label: node-primary
          type: g6-nanode-1
          region: eu-central
      # Create a secondary node
      secondary:
        type: linode:Instance
        properties:
          label: node-secondary
          type: g6-nanode-1
          region: eu-central
    

    Share an IPv6 address among a primary node and its replicas:

    import * as pulumi from "@pulumi/pulumi";
    import * as linode from "@pulumi/linode";
    
    // Create a single primary node
    const primary = new linode.Instance("primary", {
        label: "node-primary",
        type: "g6-nanode-1",
        region: "eu-central",
    });
    // Allocate an IPv6 range pointing at the primary node
    const rangeIpv6Range = new linode.Ipv6Range("range", {
        prefixLength: 64,
        linodeId: primary.id,
    });
    // Share with primary node
    const share_primary = new linode.InstanceSharedIps("share-primary", {
        linodeId: primary.id,
        addresses: [rangeIpv6Range.range],
    });
    const config = new pulumi.Config();
    const numberReplicas = config.getNumber("numberReplicas") || 2;
    // Create two secondary nodes
    const secondary: linode.Instance[] = [];
    for (const range = {value: 0}; range.value < numberReplicas; range.value++) {
        secondary.push(new linode.Instance(`secondary-${range.value}`, {
            label: `node-secondary-${range.value}`,
            type: "g6-nanode-1",
            region: "eu-central",
        }));
    }
    // Share with secondary nodes
    const share_secondary: linode.InstanceSharedIps[] = [];
    for (const range = {value: 0}; range.value < numberReplicas; range.value++) {
        share_secondary.push(new linode.InstanceSharedIps(`share-secondary-${range.value}`, {
            linodeId: secondary[range.value].id,
            addresses: [rangeIpv6Range.range],
        }, {
        dependsOn: [share_primary],
    }));
    }
    
    import pulumi
    import pulumi_linode as linode
    
    # Create a single primary node
    primary = linode.Instance("primary",
        label="node-primary",
        type="g6-nanode-1",
        region="eu-central")
    # Allocate an IPv6 range pointing at the primary node
    range_ipv6_range = linode.Ipv6Range("range",
        prefix_length=64,
        linode_id=primary.id)
    # Share with primary node
    share_primary = linode.InstanceSharedIps("share-primary",
        linode_id=primary.id,
        addresses=[range_ipv6_range.range])
    config = pulumi.Config()
    number_replicas = config.get_float("numberReplicas")
    if number_replicas is None:
        number_replicas = 2
    # Create two secondary nodes
    secondary = []
    for range in [{"value": i} for i in range(0, number_replicas)]:
        secondary.append(linode.Instance(f"secondary-{range['value']}",
            label=f"node-secondary-{range['value']}",
            type="g6-nanode-1",
            region="eu-central"))
    # Share with secondary nodes
    share_secondary = []
    for range in [{"value": i} for i in range(0, number_replicas)]:
        share_secondary.append(linode.InstanceSharedIps(f"share-secondary-{range['value']}",
            linode_id=secondary[range["value"]].id,
            addresses=[range_ipv6_range.range],
            opts = pulumi.ResourceOptions(depends_on=[share_primary])))
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-linode/sdk/v4/go/linode"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create a single primary node
    		primary, err := linode.NewInstance(ctx, "primary", &linode.InstanceArgs{
    			Label:  pulumi.String("node-primary"),
    			Type:   pulumi.String("g6-nanode-1"),
    			Region: pulumi.String("eu-central"),
    		})
    		if err != nil {
    			return err
    		}
    		// Allocate an IPv6 range pointing at the primary node
    		rangeIpv6Range, err := linode.NewIpv6Range(ctx, "range", &linode.Ipv6RangeArgs{
    			PrefixLength: pulumi.Int(64),
    			LinodeId:     primary.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		// Share with primary node
    		_, err = linode.NewInstanceSharedIps(ctx, "share-primary", &linode.InstanceSharedIpsArgs{
    			LinodeId: primary.ID(),
    			Addresses: pulumi.StringArray{
    				rangeIpv6Range.Range,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		cfg := config.New(ctx, "")
    		numberReplicas := float64(2)
    		if param := cfg.GetFloat64("numberReplicas"); param != 0 {
    			numberReplicas = param
    		}
    		// Create two secondary nodes
    		var secondary []*linode.Instance
    		for index := 0; index < numberReplicas; index++ {
    			key0 := index
    			val0 := index
    			__res, err := linode.NewInstance(ctx, fmt.Sprintf("secondary-%v", key0), &linode.InstanceArgs{
    				Label:  pulumi.Sprintf("node-secondary-%v", val0),
    				Type:   pulumi.String("g6-nanode-1"),
    				Region: pulumi.String("eu-central"),
    			})
    			if err != nil {
    				return err
    			}
    			secondary = append(secondary, __res)
    		}
    		// Share with secondary nodes
    		var share_secondary []*linode.InstanceSharedIps
    		for index := 0; index < numberReplicas; index++ {
    			key0 := index
    			val0 := index
    			__res, err := linode.NewInstanceSharedIps(ctx, fmt.Sprintf("share-secondary-%v", key0), &linode.InstanceSharedIpsArgs{
    				LinodeId: pulumi.Int(secondary[val0].ID()),
    				Addresses: pulumi.StringArray{
    					rangeIpv6Range.Range,
    				},
    			}, pulumi.DependsOn([]pulumi.Resource{
    				share_primary,
    			}))
    			if err != nil {
    				return err
    			}
    			share_secondary = append(share_secondary, __res)
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Linode = Pulumi.Linode;
    
    return await Deployment.RunAsync(() => 
    {
        // Create a single primary node
        var primary = new Linode.Instance("primary", new()
        {
            Label = "node-primary",
            Type = "g6-nanode-1",
            Region = "eu-central",
        });
    
        // Allocate an IPv6 range pointing at the primary node
        var rangeIpv6Range = new Linode.Ipv6Range("range", new()
        {
            PrefixLength = 64,
            LinodeId = primary.Id,
        });
    
        // Share with primary node
        var share_primary = new Linode.InstanceSharedIps("share-primary", new()
        {
            LinodeId = primary.Id,
            Addresses = new[]
            {
                rangeIpv6Range.Range,
            },
        });
    
        var config = new Config();
        var numberReplicas = config.GetDouble("numberReplicas") ?? 2;
        // Create two secondary nodes
        var secondary = new List<Linode.Instance>();
        for (var rangeIndex = 0; rangeIndex < numberReplicas; rangeIndex++)
        {
            var range = new { Value = rangeIndex };
            secondary.Add(new Linode.Instance($"secondary-{range.Value}", new()
            {
                Label = $"node-secondary-{range.Value}",
                Type = "g6-nanode-1",
                Region = "eu-central",
            }));
        }
        // Share with secondary nodes
        var share_secondary = new List<Linode.InstanceSharedIps>();
        for (var rangeIndex = 0; rangeIndex < numberReplicas; rangeIndex++)
        {
            var range = new { Value = rangeIndex };
            share_secondary.Add(new Linode.InstanceSharedIps($"share-secondary-{range.Value}", new()
            {
                LinodeId = secondary[range.Value].Id,
                Addresses = new[]
                {
                    rangeIpv6Range.Range,
                },
            }, new CustomResourceOptions
            {
                DependsOn =
                {
                    share_primary,
                },
            }));
        }
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.linode.Instance;
    import com.pulumi.linode.InstanceArgs;
    import com.pulumi.linode.Ipv6Range;
    import com.pulumi.linode.Ipv6RangeArgs;
    import com.pulumi.linode.InstanceSharedIps;
    import com.pulumi.linode.InstanceSharedIpsArgs;
    import com.pulumi.codegen.internal.KeyedValue;
    import com.pulumi.resources.CustomResourceOptions;
    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) {
            final var config = ctx.config();
            // Create a single primary node
            var primary = new Instance("primary", InstanceArgs.builder()
                .label("node-primary")
                .type("g6-nanode-1")
                .region("eu-central")
                .build());
    
            // Allocate an IPv6 range pointing at the primary node
            var rangeIpv6Range = new Ipv6Range("rangeIpv6Range", Ipv6RangeArgs.builder()
                .prefixLength(64)
                .linodeId(primary.id())
                .build());
    
            // Share with primary node
            var share_primary = new InstanceSharedIps("share-primary", InstanceSharedIpsArgs.builder()
                .linodeId(primary.id())
                .addresses(rangeIpv6Range.range())
                .build());
    
            final var numberReplicas = config.get("numberReplicas").orElse(2);
            // Create two secondary nodes
            for (var i = 0; i < numberReplicas; i++) {
                new Instance("secondary-" + i, InstanceArgs.builder()
                    .label(String.format("node-secondary-%s", range.value()))
                    .type("g6-nanode-1")
                    .region("eu-central")
                    .build());
    
            
    }
            // Share with secondary nodes
            for (var i = 0; i < numberReplicas; i++) {
                new InstanceSharedIps("share-secondary-" + i, InstanceSharedIpsArgs.builder()
                    .linodeId(secondary[range.value()].id())
                    .addresses(rangeIpv6Range.range())
                    .build(), CustomResourceOptions.builder()
                        .dependsOn(share_primary)
                        .build());
    
            
    }
        }
    }
    
    Coming soon!
    

    Create InstanceSharedIps Resource

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

    Constructor syntax

    new InstanceSharedIps(name: string, args: InstanceSharedIpsArgs, opts?: CustomResourceOptions);
    @overload
    def InstanceSharedIps(resource_name: str,
                          args: InstanceSharedIpsArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def InstanceSharedIps(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          addresses: Optional[Sequence[str]] = None,
                          linode_id: Optional[int] = None)
    func NewInstanceSharedIps(ctx *Context, name string, args InstanceSharedIpsArgs, opts ...ResourceOption) (*InstanceSharedIps, error)
    public InstanceSharedIps(string name, InstanceSharedIpsArgs args, CustomResourceOptions? opts = null)
    public InstanceSharedIps(String name, InstanceSharedIpsArgs args)
    public InstanceSharedIps(String name, InstanceSharedIpsArgs args, CustomResourceOptions options)
    
    type: linode:InstanceSharedIps
    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 InstanceSharedIpsArgs
    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 InstanceSharedIpsArgs
    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 InstanceSharedIpsArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args InstanceSharedIpsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args InstanceSharedIpsArgs
    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 instanceSharedIpsResource = new Linode.InstanceSharedIps("instanceSharedIpsResource", new()
    {
        Addresses = new[]
        {
            "string",
        },
        LinodeId = 0,
    });
    
    example, err := linode.NewInstanceSharedIps(ctx, "instanceSharedIpsResource", &linode.InstanceSharedIpsArgs{
    	Addresses: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	LinodeId: pulumi.Int(0),
    })
    
    var instanceSharedIpsResource = new InstanceSharedIps("instanceSharedIpsResource", InstanceSharedIpsArgs.builder()
        .addresses("string")
        .linodeId(0)
        .build());
    
    instance_shared_ips_resource = linode.InstanceSharedIps("instanceSharedIpsResource",
        addresses=["string"],
        linode_id=0)
    
    const instanceSharedIpsResource = new linode.InstanceSharedIps("instanceSharedIpsResource", {
        addresses: ["string"],
        linodeId: 0,
    });
    
    type: linode:InstanceSharedIps
    properties:
        addresses:
            - string
        linodeId: 0
    

    InstanceSharedIps 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 InstanceSharedIps resource accepts the following input properties:

    Addresses List<string>
    The set of IPs to share with the Linode.
    LinodeId int
    The ID of the Linode to share the IPs to.
    Addresses []string
    The set of IPs to share with the Linode.
    LinodeId int
    The ID of the Linode to share the IPs to.
    addresses List<String>
    The set of IPs to share with the Linode.
    linodeId Integer
    The ID of the Linode to share the IPs to.
    addresses string[]
    The set of IPs to share with the Linode.
    linodeId number
    The ID of the Linode to share the IPs to.
    addresses Sequence[str]
    The set of IPs to share with the Linode.
    linode_id int
    The ID of the Linode to share the IPs to.
    addresses List<String>
    The set of IPs to share with the Linode.
    linodeId Number
    The ID of the Linode to share the IPs to.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the InstanceSharedIps 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 InstanceSharedIps Resource

    Get an existing InstanceSharedIps 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?: InstanceSharedIpsState, opts?: CustomResourceOptions): InstanceSharedIps
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            addresses: Optional[Sequence[str]] = None,
            linode_id: Optional[int] = None) -> InstanceSharedIps
    func GetInstanceSharedIps(ctx *Context, name string, id IDInput, state *InstanceSharedIpsState, opts ...ResourceOption) (*InstanceSharedIps, error)
    public static InstanceSharedIps Get(string name, Input<string> id, InstanceSharedIpsState? state, CustomResourceOptions? opts = null)
    public static InstanceSharedIps get(String name, Output<String> id, InstanceSharedIpsState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    Addresses List<string>
    The set of IPs to share with the Linode.
    LinodeId int
    The ID of the Linode to share the IPs to.
    Addresses []string
    The set of IPs to share with the Linode.
    LinodeId int
    The ID of the Linode to share the IPs to.
    addresses List<String>
    The set of IPs to share with the Linode.
    linodeId Integer
    The ID of the Linode to share the IPs to.
    addresses string[]
    The set of IPs to share with the Linode.
    linodeId number
    The ID of the Linode to share the IPs to.
    addresses Sequence[str]
    The set of IPs to share with the Linode.
    linode_id int
    The ID of the Linode to share the IPs to.
    addresses List<String>
    The set of IPs to share with the Linode.
    linodeId Number
    The ID of the Linode to share the IPs to.

    Package Details

    Repository
    Linode pulumi/pulumi-linode
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the linode Terraform Provider.
    linode logo
    Linode v4.30.1 published on Thursday, Nov 21, 2024 by Pulumi