1. Packages
  2. Ucloud Provider
  3. API Docs
  4. Vpc
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

ucloud.Vpc

Explore with Pulumi AI

Provides a VPC resource.

Note The network segment can only be created or deleted, can not perform both of them at the same time.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as ucloud from "@pulumi/ucloud";

const example = new ucloud.Vpc("example", {
    cidrBlocks: ["192.168.0.0/16"],
    tag: "tf-example",
});
Copy
import pulumi
import pulumi_ucloud as ucloud

example = ucloud.Vpc("example",
    cidr_blocks=["192.168.0.0/16"],
    tag="tf-example")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ucloud.NewVpc(ctx, "example", &ucloud.VpcArgs{
			CidrBlocks: pulumi.StringArray{
				pulumi.String("192.168.0.0/16"),
			},
			Tag: pulumi.String("tf-example"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ucloud = Pulumi.Ucloud;

return await Deployment.RunAsync(() => 
{
    var example = new Ucloud.Vpc("example", new()
    {
        CidrBlocks = new[]
        {
            "192.168.0.0/16",
        },
        Tag = "tf-example",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ucloud.Vpc;
import com.pulumi.ucloud.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()
            .cidrBlocks("192.168.0.0/16")
            .tag("tf-example")
            .build());

    }
}
Copy
resources:
  example:
    type: ucloud:Vpc
    properties:
      # vpc network
      cidrBlocks:
        - 192.168.0.0/16
      tag: tf-example
Copy

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,
        cidr_blocks: Optional[Sequence[str]] = None,
        name: Optional[str] = None,
        remark: Optional[str] = None,
        tag: Optional[str] = None,
        vpc_id: 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: ucloud:Vpc
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. VpcArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. VpcArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. VpcArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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 Ucloud.Vpc("vpcResource", new()
{
    CidrBlocks = new[]
    {
        "string",
    },
    Name = "string",
    Remark = "string",
    Tag = "string",
    VpcId = "string",
});
Copy
example, err := ucloud.NewVpc(ctx, "vpcResource", &ucloud.VpcArgs{
CidrBlocks: pulumi.StringArray{
pulumi.String("string"),
},
Name: pulumi.String("string"),
Remark: pulumi.String("string"),
Tag: pulumi.String("string"),
VpcId: pulumi.String("string"),
})
Copy
var vpcResource = new Vpc("vpcResource", VpcArgs.builder()
    .cidrBlocks("string")
    .name("string")
    .remark("string")
    .tag("string")
    .vpcId("string")
    .build());
Copy
vpc_resource = ucloud.Vpc("vpcResource",
    cidr_blocks=["string"],
    name="string",
    remark="string",
    tag="string",
    vpc_id="string")
Copy
const vpcResource = new ucloud.Vpc("vpcResource", {
    cidrBlocks: ["string"],
    name: "string",
    remark: "string",
    tag: "string",
    vpcId: "string",
});
Copy
type: ucloud:Vpc
properties:
    cidrBlocks:
        - string
    name: string
    remark: string
    tag: string
    vpcId: string
Copy

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

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

The Vpc resource accepts the following input properties:

CidrBlocks This property is required. List<string>
The CIDR blocks of VPC.


Name string
Remark string
The remarks of the VPC. (Default: "").
Tag string
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
VpcId string
The ID of the resource VPC.
CidrBlocks This property is required. []string
The CIDR blocks of VPC.


Name string
Remark string
The remarks of the VPC. (Default: "").
Tag string
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
VpcId string
The ID of the resource VPC.
cidrBlocks This property is required. List<String>
The CIDR blocks of VPC.


name String
remark String
The remarks of the VPC. (Default: "").
tag String
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
vpcId String
The ID of the resource VPC.
cidrBlocks This property is required. string[]
The CIDR blocks of VPC.


name string
remark string
The remarks of the VPC. (Default: "").
tag string
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
vpcId string
The ID of the resource VPC.
cidr_blocks This property is required. Sequence[str]
The CIDR blocks of VPC.


name str
remark str
The remarks of the VPC. (Default: "").
tag str
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
vpc_id str
The ID of the resource VPC.
cidrBlocks This property is required. List<String>
The CIDR blocks of VPC.


name String
remark String
The remarks of the VPC. (Default: "").
tag String
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
vpcId String
The ID of the resource VPC.

Outputs

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

CreateTime string
The time of creation for VPC, formatted in RFC3339 time string.
Id string
The provider-assigned unique ID for this managed resource.
NetworkInfos List<VpcNetworkInfo>
It is a nested type which documented below.
UpdateTime string
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
CreateTime string
The time of creation for VPC, formatted in RFC3339 time string.
Id string
The provider-assigned unique ID for this managed resource.
NetworkInfos []VpcNetworkInfo
It is a nested type which documented below.
UpdateTime string
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
createTime String
The time of creation for VPC, formatted in RFC3339 time string.
id String
The provider-assigned unique ID for this managed resource.
networkInfos List<VpcNetworkInfo>
It is a nested type which documented below.
updateTime String
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
createTime string
The time of creation for VPC, formatted in RFC3339 time string.
id string
The provider-assigned unique ID for this managed resource.
networkInfos VpcNetworkInfo[]
It is a nested type which documented below.
updateTime string
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
create_time str
The time of creation for VPC, formatted in RFC3339 time string.
id str
The provider-assigned unique ID for this managed resource.
network_infos Sequence[VpcNetworkInfo]
It is a nested type which documented below.
update_time str
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
createTime String
The time of creation for VPC, formatted in RFC3339 time string.
id String
The provider-assigned unique ID for this managed resource.
networkInfos List<Property Map>
It is a nested type which documented below.
updateTime String
The time whenever there is a change made to VPC, formatted in RFC3339 time string.

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,
        cidr_blocks: Optional[Sequence[str]] = None,
        create_time: Optional[str] = None,
        name: Optional[str] = None,
        network_infos: Optional[Sequence[VpcNetworkInfoArgs]] = None,
        remark: Optional[str] = None,
        tag: Optional[str] = None,
        update_time: Optional[str] = None,
        vpc_id: 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)
resources:  _:    type: ucloud:Vpc    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
CidrBlocks List<string>
The CIDR blocks of VPC.


CreateTime string
The time of creation for VPC, formatted in RFC3339 time string.
Name string
NetworkInfos List<VpcNetworkInfo>
It is a nested type which documented below.
Remark string
The remarks of the VPC. (Default: "").
Tag string
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
UpdateTime string
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
VpcId string
The ID of the resource VPC.
CidrBlocks []string
The CIDR blocks of VPC.


CreateTime string
The time of creation for VPC, formatted in RFC3339 time string.
Name string
NetworkInfos []VpcNetworkInfoArgs
It is a nested type which documented below.
Remark string
The remarks of the VPC. (Default: "").
Tag string
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
UpdateTime string
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
VpcId string
The ID of the resource VPC.
cidrBlocks List<String>
The CIDR blocks of VPC.


createTime String
The time of creation for VPC, formatted in RFC3339 time string.
name String
networkInfos List<VpcNetworkInfo>
It is a nested type which documented below.
remark String
The remarks of the VPC. (Default: "").
tag String
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
updateTime String
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
vpcId String
The ID of the resource VPC.
cidrBlocks string[]
The CIDR blocks of VPC.


createTime string
The time of creation for VPC, formatted in RFC3339 time string.
name string
networkInfos VpcNetworkInfo[]
It is a nested type which documented below.
remark string
The remarks of the VPC. (Default: "").
tag string
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
updateTime string
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
vpcId string
The ID of the resource VPC.
cidr_blocks Sequence[str]
The CIDR blocks of VPC.


create_time str
The time of creation for VPC, formatted in RFC3339 time string.
name str
network_infos Sequence[VpcNetworkInfoArgs]
It is a nested type which documented below.
remark str
The remarks of the VPC. (Default: "").
tag str
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
update_time str
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
vpc_id str
The ID of the resource VPC.
cidrBlocks List<String>
The CIDR blocks of VPC.


createTime String
The time of creation for VPC, formatted in RFC3339 time string.
name String
networkInfos List<Property Map>
It is a nested type which documented below.
remark String
The remarks of the VPC. (Default: "").
tag String
A tag assigned to VPC, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default: Default).
updateTime String
The time whenever there is a change made to VPC, formatted in RFC3339 time string.
vpcId String
The ID of the resource VPC.

Supporting Types

VpcNetworkInfo
, VpcNetworkInfoArgs

CidrBlock This property is required. string
The CIDR block of the VPC.
CidrBlock This property is required. string
The CIDR block of the VPC.
cidrBlock This property is required. String
The CIDR block of the VPC.
cidrBlock This property is required. string
The CIDR block of the VPC.
cidr_block This property is required. str
The CIDR block of the VPC.
cidrBlock This property is required. String
The CIDR block of the VPC.

Import

VPC can be imported using the id, e.g.

$ pulumi import ucloud:index/vpc:Vpc example uvnet-abc123456
Copy

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

Package Details

Repository
ucloud ucloud/terraform-provider-ucloud
License
Notes
This Pulumi package is based on the ucloud Terraform Provider.