1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. VpcPeering
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

digitalocean.VpcPeering

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

    VPC peering is currently in alpha. If you are not a member of the alpha group for this feature, you will not be able to use it until it has been more widely released. Please follow the official DigitalOcean changelog for updates.

    Provides a DigitalOcean VPC Peering resource.

    VPC Peerings are used to connect two VPC networks allowing resources in each VPC to communicate with each other privately.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example = new digitalocean.VpcPeering("example", {
        name: "example-peering",
        vpcIds: [
            vpc1.id,
            vpc2.id,
        ],
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example = digitalocean.VpcPeering("example",
        name="example-peering",
        vpc_ids=[
            vpc1["id"],
            vpc2["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 {
    		_, err := digitalocean.NewVpcPeering(ctx, "example", &digitalocean.VpcPeeringArgs{
    			Name: pulumi.String("example-peering"),
    			VpcIds: pulumi.StringArray{
    				vpc1.Id,
    				vpc2.Id,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new DigitalOcean.VpcPeering("example", new()
        {
            Name = "example-peering",
            VpcIds = new[]
            {
                vpc1.Id,
                vpc2.Id,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.VpcPeering;
    import com.pulumi.digitalocean.VpcPeeringArgs;
    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 VpcPeering("example", VpcPeeringArgs.builder()
                .name("example-peering")
                .vpcIds(            
                    vpc1.id(),
                    vpc2.id())
                .build());
    
        }
    }
    
    resources:
      example:
        type: digitalocean:VpcPeering
        properties:
          name: example-peering
          vpcIds:
            - ${vpc1.id}
            - ${vpc2.id}
    

    Resource Assignment

    You can use the VPC Peering resource to allow communication between resources in different VPCs. For example:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const vpc1 = new digitalocean.Vpc("vpc1", {
        name: "vpc1",
        region: "nyc3",
    });
    const vpc2 = new digitalocean.Vpc("vpc2", {
        name: "vpc2",
        region: "nyc3",
    });
    const example = new digitalocean.VpcPeering("example", {
        name: "example-peering",
        vpcIds: [
            vpc1.id,
            vpc2.id,
        ],
    });
    const example1 = new digitalocean.Droplet("example1", {
        name: "example1",
        size: digitalocean.DropletSlug.DropletS1VCPU1GB,
        image: "ubuntu-18-04-x64",
        region: digitalocean.Region.NYC3,
        vpcUuid: vpc1.id,
    });
    const example2 = new digitalocean.Droplet("example2", {
        name: "example2",
        size: digitalocean.DropletSlug.DropletS1VCPU1GB,
        image: "ubuntu-18-04-x64",
        region: digitalocean.Region.NYC3,
        vpcUuid: vpc2.id,
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    vpc1 = digitalocean.Vpc("vpc1",
        name="vpc1",
        region="nyc3")
    vpc2 = digitalocean.Vpc("vpc2",
        name="vpc2",
        region="nyc3")
    example = digitalocean.VpcPeering("example",
        name="example-peering",
        vpc_ids=[
            vpc1.id,
            vpc2.id,
        ])
    example1 = digitalocean.Droplet("example1",
        name="example1",
        size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
        image="ubuntu-18-04-x64",
        region=digitalocean.Region.NYC3,
        vpc_uuid=vpc1.id)
    example2 = digitalocean.Droplet("example2",
        name="example2",
        size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
        image="ubuntu-18-04-x64",
        region=digitalocean.Region.NYC3,
        vpc_uuid=vpc2.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 {
    		vpc1, err := digitalocean.NewVpc(ctx, "vpc1", &digitalocean.VpcArgs{
    			Name:   pulumi.String("vpc1"),
    			Region: pulumi.String("nyc3"),
    		})
    		if err != nil {
    			return err
    		}
    		vpc2, err := digitalocean.NewVpc(ctx, "vpc2", &digitalocean.VpcArgs{
    			Name:   pulumi.String("vpc2"),
    			Region: pulumi.String("nyc3"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewVpcPeering(ctx, "example", &digitalocean.VpcPeeringArgs{
    			Name: pulumi.String("example-peering"),
    			VpcIds: pulumi.StringArray{
    				vpc1.ID(),
    				vpc2.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewDroplet(ctx, "example1", &digitalocean.DropletArgs{
    			Name:    pulumi.String("example1"),
    			Size:    pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
    			Image:   pulumi.String("ubuntu-18-04-x64"),
    			Region:  pulumi.String(digitalocean.RegionNYC3),
    			VpcUuid: vpc1.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewDroplet(ctx, "example2", &digitalocean.DropletArgs{
    			Name:    pulumi.String("example2"),
    			Size:    pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
    			Image:   pulumi.String("ubuntu-18-04-x64"),
    			Region:  pulumi.String(digitalocean.RegionNYC3),
    			VpcUuid: vpc2.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var vpc1 = new DigitalOcean.Vpc("vpc1", new()
        {
            Name = "vpc1",
            Region = "nyc3",
        });
    
        var vpc2 = new DigitalOcean.Vpc("vpc2", new()
        {
            Name = "vpc2",
            Region = "nyc3",
        });
    
        var example = new DigitalOcean.VpcPeering("example", new()
        {
            Name = "example-peering",
            VpcIds = new[]
            {
                vpc1.Id,
                vpc2.Id,
            },
        });
    
        var example1 = new DigitalOcean.Droplet("example1", new()
        {
            Name = "example1",
            Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
            Image = "ubuntu-18-04-x64",
            Region = DigitalOcean.Region.NYC3,
            VpcUuid = vpc1.Id,
        });
    
        var example2 = new DigitalOcean.Droplet("example2", new()
        {
            Name = "example2",
            Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
            Image = "ubuntu-18-04-x64",
            Region = DigitalOcean.Region.NYC3,
            VpcUuid = vpc2.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.Vpc;
    import com.pulumi.digitalocean.VpcArgs;
    import com.pulumi.digitalocean.VpcPeering;
    import com.pulumi.digitalocean.VpcPeeringArgs;
    import com.pulumi.digitalocean.Droplet;
    import com.pulumi.digitalocean.DropletArgs;
    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 vpc1 = new Vpc("vpc1", VpcArgs.builder()
                .name("vpc1")
                .region("nyc3")
                .build());
    
            var vpc2 = new Vpc("vpc2", VpcArgs.builder()
                .name("vpc2")
                .region("nyc3")
                .build());
    
            var example = new VpcPeering("example", VpcPeeringArgs.builder()
                .name("example-peering")
                .vpcIds(            
                    vpc1.id(),
                    vpc2.id())
                .build());
    
            var example1 = new Droplet("example1", DropletArgs.builder()
                .name("example1")
                .size("s-1vcpu-1gb")
                .image("ubuntu-18-04-x64")
                .region("nyc3")
                .vpcUuid(vpc1.id())
                .build());
    
            var example2 = new Droplet("example2", DropletArgs.builder()
                .name("example2")
                .size("s-1vcpu-1gb")
                .image("ubuntu-18-04-x64")
                .region("nyc3")
                .vpcUuid(vpc2.id())
                .build());
    
        }
    }
    
    resources:
      vpc1:
        type: digitalocean:Vpc
        properties:
          name: vpc1
          region: nyc3
      vpc2:
        type: digitalocean:Vpc
        properties:
          name: vpc2
          region: nyc3
      example:
        type: digitalocean:VpcPeering
        properties:
          name: example-peering
          vpcIds:
            - ${vpc1.id}
            - ${vpc2.id}
      example1:
        type: digitalocean:Droplet
        properties:
          name: example1
          size: s-1vcpu-1gb
          image: ubuntu-18-04-x64
          region: nyc3
          vpcUuid: ${vpc1.id}
      example2:
        type: digitalocean:Droplet
        properties:
          name: example2
          size: s-1vcpu-1gb
          image: ubuntu-18-04-x64
          region: nyc3
          vpcUuid: ${vpc2.id}
    

    Create VpcPeering Resource

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

    Constructor syntax

    new VpcPeering(name: string, args: VpcPeeringArgs, opts?: CustomResourceOptions);
    @overload
    def VpcPeering(resource_name: str,
                   args: VpcPeeringArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def VpcPeering(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   vpc_ids: Optional[Sequence[str]] = None,
                   name: Optional[str] = None)
    func NewVpcPeering(ctx *Context, name string, args VpcPeeringArgs, opts ...ResourceOption) (*VpcPeering, error)
    public VpcPeering(string name, VpcPeeringArgs args, CustomResourceOptions? opts = null)
    public VpcPeering(String name, VpcPeeringArgs args)
    public VpcPeering(String name, VpcPeeringArgs args, CustomResourceOptions options)
    
    type: digitalocean:VpcPeering
    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 VpcPeeringArgs
    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 VpcPeeringArgs
    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 VpcPeeringArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args VpcPeeringArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args VpcPeeringArgs
    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 vpcPeeringResource = new DigitalOcean.VpcPeering("vpcPeeringResource", new()
    {
        VpcIds = new[]
        {
            "string",
        },
        Name = "string",
    });
    
    example, err := digitalocean.NewVpcPeering(ctx, "vpcPeeringResource", &digitalocean.VpcPeeringArgs{
    	VpcIds: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Name: pulumi.String("string"),
    })
    
    var vpcPeeringResource = new VpcPeering("vpcPeeringResource", VpcPeeringArgs.builder()
        .vpcIds("string")
        .name("string")
        .build());
    
    vpc_peering_resource = digitalocean.VpcPeering("vpcPeeringResource",
        vpc_ids=["string"],
        name="string")
    
    const vpcPeeringResource = new digitalocean.VpcPeering("vpcPeeringResource", {
        vpcIds: ["string"],
        name: "string",
    });
    
    type: digitalocean:VpcPeering
    properties:
        name: string
        vpcIds:
            - string
    

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

    VpcIds List<string>
    A set of two VPC IDs to be peered.
    Name string
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    VpcIds []string
    A set of two VPC IDs to be peered.
    Name string
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    vpcIds List<String>
    A set of two VPC IDs to be peered.
    name String
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    vpcIds string[]
    A set of two VPC IDs to be peered.
    name string
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    vpc_ids Sequence[str]
    A set of two VPC IDs to be peered.
    name str
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    vpcIds List<String>
    A set of two VPC IDs to be peered.
    name String
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.

    Outputs

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

    CreatedAt string
    The date and time of when the VPC Peering was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The status of the VPC Peering.
    CreatedAt string
    The date and time of when the VPC Peering was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The status of the VPC Peering.
    createdAt String
    The date and time of when the VPC Peering was created.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The status of the VPC Peering.
    createdAt string
    The date and time of when the VPC Peering was created.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    The status of the VPC Peering.
    created_at str
    The date and time of when the VPC Peering was created.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    The status of the VPC Peering.
    createdAt String
    The date and time of when the VPC Peering was created.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The status of the VPC Peering.

    Look up Existing VpcPeering Resource

    Get an existing VpcPeering 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?: VpcPeeringState, opts?: CustomResourceOptions): VpcPeering
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            created_at: Optional[str] = None,
            name: Optional[str] = None,
            status: Optional[str] = None,
            vpc_ids: Optional[Sequence[str]] = None) -> VpcPeering
    func GetVpcPeering(ctx *Context, name string, id IDInput, state *VpcPeeringState, opts ...ResourceOption) (*VpcPeering, error)
    public static VpcPeering Get(string name, Input<string> id, VpcPeeringState? state, CustomResourceOptions? opts = null)
    public static VpcPeering get(String name, Output<String> id, VpcPeeringState 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:
    CreatedAt string
    The date and time of when the VPC Peering was created.
    Name string
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    Status string
    The status of the VPC Peering.
    VpcIds List<string>
    A set of two VPC IDs to be peered.
    CreatedAt string
    The date and time of when the VPC Peering was created.
    Name string
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    Status string
    The status of the VPC Peering.
    VpcIds []string
    A set of two VPC IDs to be peered.
    createdAt String
    The date and time of when the VPC Peering was created.
    name String
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    status String
    The status of the VPC Peering.
    vpcIds List<String>
    A set of two VPC IDs to be peered.
    createdAt string
    The date and time of when the VPC Peering was created.
    name string
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    status string
    The status of the VPC Peering.
    vpcIds string[]
    A set of two VPC IDs to be peered.
    created_at str
    The date and time of when the VPC Peering was created.
    name str
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    status str
    The status of the VPC Peering.
    vpc_ids Sequence[str]
    A set of two VPC IDs to be peered.
    createdAt String
    The date and time of when the VPC Peering was created.
    name String
    A name for the VPC Peering. Must be unique and contain alphanumeric characters, dashes, and periods only.
    status String
    The status of the VPC Peering.
    vpcIds List<String>
    A set of two VPC IDs to be peered.

    Import

    A VPC Peering can be imported using its id, e.g.

    $ pulumi import digitalocean:index/vpcPeering:VpcPeering example 771ad360-c017-4b4e-a34e-73934f5f0190
    

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

    Package Details

    Repository
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the digitalocean Terraform Provider.
    digitalocean logo
    DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi