1. Packages
  2. DigitalOcean
  3. API Docs
  4. Vpc
DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi

digitalocean.Vpc

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi

    Provides a DigitalOcean VPC resource.

    VPCs are virtual networks containing resources that can communicate with each other in full isolation, using private IP addresses.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example = new digitalocean.Vpc("example", {
        name: "example-project-network",
        region: "nyc3",
        ipRange: "10.10.10.0/24",
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example = digitalocean.Vpc("example",
        name="example-project-network",
        region="nyc3",
        ip_range="10.10.10.0/24")
    
    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.NewVpc(ctx, "example", &digitalocean.VpcArgs{
    			Name:    pulumi.String("example-project-network"),
    			Region:  pulumi.String("nyc3"),
    			IpRange: pulumi.String("10.10.10.0/24"),
    		})
    		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.Vpc("example", new()
        {
            Name = "example-project-network",
            Region = "nyc3",
            IpRange = "10.10.10.0/24",
        });
    
    });
    
    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 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 Vpc("example", VpcArgs.builder()
                .name("example-project-network")
                .region("nyc3")
                .ipRange("10.10.10.0/24")
                .build());
    
        }
    }
    
    resources:
      example:
        type: digitalocean:Vpc
        properties:
          name: example-project-network
          region: nyc3
          ipRange: 10.10.10.0/24
    

    Resource Assignment

    digitalocean.Droplet, digitalocean.KubernetesCluster, digitalocean_load_balancer, and digitalocean.DatabaseCluster resources may be assigned to a VPC by referencing its id. For example:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example = new digitalocean.Vpc("example", {
        name: "example-project-network",
        region: "nyc3",
    });
    const exampleDroplet = new digitalocean.Droplet("example", {
        name: "example-01",
        size: digitalocean.DropletSlug.DropletS1VCPU1GB,
        image: "ubuntu-18-04-x64",
        region: digitalocean.Region.NYC3,
        vpcUuid: example.id,
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example = digitalocean.Vpc("example",
        name="example-project-network",
        region="nyc3")
    example_droplet = digitalocean.Droplet("example",
        name="example-01",
        size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
        image="ubuntu-18-04-x64",
        region=digitalocean.Region.NYC3,
        vpc_uuid=example.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 {
    		example, err := digitalocean.NewVpc(ctx, "example", &digitalocean.VpcArgs{
    			Name:   pulumi.String("example-project-network"),
    			Region: pulumi.String("nyc3"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewDroplet(ctx, "example", &digitalocean.DropletArgs{
    			Name:    pulumi.String("example-01"),
    			Size:    pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
    			Image:   pulumi.String("ubuntu-18-04-x64"),
    			Region:  pulumi.String(digitalocean.RegionNYC3),
    			VpcUuid: example.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.Vpc("example", new()
        {
            Name = "example-project-network",
            Region = "nyc3",
        });
    
        var exampleDroplet = new DigitalOcean.Droplet("example", new()
        {
            Name = "example-01",
            Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
            Image = "ubuntu-18-04-x64",
            Region = DigitalOcean.Region.NYC3,
            VpcUuid = example.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.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 example = new Vpc("example", VpcArgs.builder()
                .name("example-project-network")
                .region("nyc3")
                .build());
    
            var exampleDroplet = new Droplet("exampleDroplet", DropletArgs.builder()
                .name("example-01")
                .size("s-1vcpu-1gb")
                .image("ubuntu-18-04-x64")
                .region("nyc3")
                .vpcUuid(example.id())
                .build());
    
        }
    }
    
    resources:
      example:
        type: digitalocean:Vpc
        properties:
          name: example-project-network
          region: nyc3
      exampleDroplet:
        type: digitalocean:Droplet
        name: example
        properties:
          name: example-01
          size: s-1vcpu-1gb
          image: ubuntu-18-04-x64
          region: nyc3
          vpcUuid: ${example.id}
    

    Create Vpc Resource

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

    Constructor syntax

    new Vpc(name: string, args: VpcArgs, opts?: CustomResourceOptions);
    @overload
    def Vpc(resource_name: str,
            args: VpcArgs,
            opts: Optional[ResourceOptions] = None)
    
    @overload
    def Vpc(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            region: Optional[str] = None,
            description: Optional[str] = None,
            ip_range: Optional[str] = None,
            name: Optional[str] = None)
    func NewVpc(ctx *Context, name string, args VpcArgs, opts ...ResourceOption) (*Vpc, error)
    public Vpc(string name, VpcArgs args, CustomResourceOptions? opts = null)
    public Vpc(String name, VpcArgs args)
    public Vpc(String name, VpcArgs args, CustomResourceOptions options)
    
    type: digitalocean:Vpc
    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 VpcArgs
    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 VpcArgs
    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 VpcArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args VpcArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args VpcArgs
    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 vpcResource = new DigitalOcean.Vpc("vpcResource", new()
    {
        Region = "string",
        Description = "string",
        IpRange = "string",
        Name = "string",
    });
    
    example, err := digitalocean.NewVpc(ctx, "vpcResource", &digitalocean.VpcArgs{
    	Region:      pulumi.String("string"),
    	Description: pulumi.String("string"),
    	IpRange:     pulumi.String("string"),
    	Name:        pulumi.String("string"),
    })
    
    var vpcResource = new Vpc("vpcResource", VpcArgs.builder()
        .region("string")
        .description("string")
        .ipRange("string")
        .name("string")
        .build());
    
    vpc_resource = digitalocean.Vpc("vpcResource",
        region="string",
        description="string",
        ip_range="string",
        name="string")
    
    const vpcResource = new digitalocean.Vpc("vpcResource", {
        region: "string",
        description: "string",
        ipRange: "string",
        name: "string",
    });
    
    type: digitalocean:Vpc
    properties:
        description: string
        ipRange: string
        name: string
        region: string
    

    Vpc Resource Properties

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

    Inputs

    The Vpc resource accepts the following input properties:

    Region string
    The DigitalOcean region slug for the VPC's location.
    Description string
    A free-form text field up to a limit of 255 characters to describe the VPC.
    IpRange string
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    Name string
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    Region string
    The DigitalOcean region slug for the VPC's location.
    Description string
    A free-form text field up to a limit of 255 characters to describe the VPC.
    IpRange string
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    Name string
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region String
    The DigitalOcean region slug for the VPC's location.
    description String
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ipRange String
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name String
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region string
    The DigitalOcean region slug for the VPC's location.
    description string
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ipRange string
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name string
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region str
    The DigitalOcean region slug for the VPC's location.
    description str
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ip_range str
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name str
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region String
    The DigitalOcean region slug for the VPC's location.
    description String
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ipRange String
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name String
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.

    Outputs

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

    CreatedAt string
    The date and time of when the VPC was created.
    Default bool
    A boolean indicating whether or not the VPC is the default one for the region.
    Id string
    The provider-assigned unique ID for this managed resource.
    VpcUrn string
    The uniform resource name (URN) for the VPC.
    CreatedAt string
    The date and time of when the VPC was created.
    Default bool
    A boolean indicating whether or not the VPC is the default one for the region.
    Id string
    The provider-assigned unique ID for this managed resource.
    VpcUrn string
    The uniform resource name (URN) for the VPC.
    createdAt String
    The date and time of when the VPC was created.
    default_ Boolean
    A boolean indicating whether or not the VPC is the default one for the region.
    id String
    The provider-assigned unique ID for this managed resource.
    vpcUrn String
    The uniform resource name (URN) for the VPC.
    createdAt string
    The date and time of when the VPC was created.
    default boolean
    A boolean indicating whether or not the VPC is the default one for the region.
    id string
    The provider-assigned unique ID for this managed resource.
    vpcUrn string
    The uniform resource name (URN) for the VPC.
    created_at str
    The date and time of when the VPC was created.
    default bool
    A boolean indicating whether or not the VPC is the default one for the region.
    id str
    The provider-assigned unique ID for this managed resource.
    vpc_urn str
    The uniform resource name (URN) for the VPC.
    createdAt String
    The date and time of when the VPC was created.
    default Boolean
    A boolean indicating whether or not the VPC is the default one for the region.
    id String
    The provider-assigned unique ID for this managed resource.
    vpcUrn String
    The uniform resource name (URN) for the VPC.

    Look up Existing Vpc Resource

    Get an existing Vpc 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?: VpcState, opts?: CustomResourceOptions): Vpc
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            created_at: Optional[str] = None,
            default: Optional[bool] = None,
            description: Optional[str] = None,
            ip_range: Optional[str] = None,
            name: Optional[str] = None,
            region: Optional[str] = None,
            vpc_urn: Optional[str] = None) -> Vpc
    func GetVpc(ctx *Context, name string, id IDInput, state *VpcState, opts ...ResourceOption) (*Vpc, error)
    public static Vpc Get(string name, Input<string> id, VpcState? state, CustomResourceOptions? opts = null)
    public static Vpc get(String name, Output<String> id, VpcState 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 was created.
    Default bool
    A boolean indicating whether or not the VPC is the default one for the region.
    Description string
    A free-form text field up to a limit of 255 characters to describe the VPC.
    IpRange string
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    Name string
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    Region string
    The DigitalOcean region slug for the VPC's location.
    VpcUrn string
    The uniform resource name (URN) for the VPC.
    CreatedAt string
    The date and time of when the VPC was created.
    Default bool
    A boolean indicating whether or not the VPC is the default one for the region.
    Description string
    A free-form text field up to a limit of 255 characters to describe the VPC.
    IpRange string
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    Name string
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    Region string
    The DigitalOcean region slug for the VPC's location.
    VpcUrn string
    The uniform resource name (URN) for the VPC.
    createdAt String
    The date and time of when the VPC was created.
    default_ Boolean
    A boolean indicating whether or not the VPC is the default one for the region.
    description String
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ipRange String
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name String
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region String
    The DigitalOcean region slug for the VPC's location.
    vpcUrn String
    The uniform resource name (URN) for the VPC.
    createdAt string
    The date and time of when the VPC was created.
    default boolean
    A boolean indicating whether or not the VPC is the default one for the region.
    description string
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ipRange string
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name string
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region string
    The DigitalOcean region slug for the VPC's location.
    vpcUrn string
    The uniform resource name (URN) for the VPC.
    created_at str
    The date and time of when the VPC was created.
    default bool
    A boolean indicating whether or not the VPC is the default one for the region.
    description str
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ip_range str
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name str
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region str
    The DigitalOcean region slug for the VPC's location.
    vpc_urn str
    The uniform resource name (URN) for the VPC.
    createdAt String
    The date and time of when the VPC was created.
    default Boolean
    A boolean indicating whether or not the VPC is the default one for the region.
    description String
    A free-form text field up to a limit of 255 characters to describe the VPC.
    ipRange String
    The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24.
    name String
    A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only.
    region String
    The DigitalOcean region slug for the VPC's location.
    vpcUrn String
    The uniform resource name (URN) for the VPC.

    Import

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

    $ pulumi import digitalocean:index/vpc:Vpc example 506f78a4-e098-11e5-ad9f-000f53306ae1
    

    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.30.2 published on Wednesday, Jun 5, 2024 by Pulumi