title: "Vpc" title_tag: "huaweicloud.Vpc.Vpc" meta_desc: "Documentation for the huaweicloud.Vpc.Vpc resource with examples, input properties, output properties, lookup functions, and supporting types." layout: api no_edit_this_page: true


Manages a VPC resource within HuaweiCloud.

## Example Usage
using System.Collections.Generic;
using Pulumi;
using Huaweicloud = Pulumi.Huaweicloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var vpcName = config.Get("vpcName") ?? "huaweicloud_vpc";
    var vpcCidr = config.Get("vpcCidr") ?? "192.168.0.0/16";
    var vpc = new Huaweicloud.Vpc.Vpc("vpc", new()
    {
        Cidr = vpcCidr,
    });

    var vpcWithTags = new Huaweicloud.Vpc.Vpc("vpcWithTags", new()
    {
        Cidr = vpcCidr,
        Tags = 
        {
            { "foo", "bar" },
            { "key", "value" },
        },
    });

});
package main

import (
    "github.com/huaweicloud/pulumi-huaweicloud/sdk/go/huaweicloud/Vpc"
    "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 {
        cfg := config.New(ctx, "")
        vpcName := "huaweicloud_vpc"
        if param := cfg.Get("vpcName"); param != "" {
            vpcName = param
        }
        vpcCidr := "192.168.0.0/16"
        if param := cfg.Get("vpcCidr"); param != "" {
            vpcCidr = param
        }
        _, err := Vpc.NewVpc(ctx, "vpc", &Vpc.VpcArgs{
            Cidr: pulumi.String(vpcCidr),
        })
        if err != nil {
            return err
        }
        _, err = Vpc.NewVpc(ctx, "vpcWithTags", &Vpc.VpcArgs{
            Cidr: pulumi.String(vpcCidr),
            Tags: pulumi.StringMap{
                "foo": pulumi.String("bar"),
                "key": pulumi.String("value"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.huaweicloud.Vpc.Vpc;
import com.pulumi.huaweicloud.Vpc.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) {
        final var config = ctx.config();
        final var vpcName = config.get("vpcName").orElse("huaweicloud_vpc");
        final var vpcCidr = config.get("vpcCidr").orElse("192.168.0.0/16");
        var vpc = new Vpc("vpc", VpcArgs.builder()        
            .cidr(vpcCidr)
            .build());

        var vpcWithTags = new Vpc("vpcWithTags", VpcArgs.builder()        
            .cidr(vpcCidr)
            .tags(Map.ofEntries(
                Map.entry("foo", "bar"),
                Map.entry("key", "value")
            ))
            .build());

    }
}
import pulumi
import pulumi_huaweicloud as huaweicloud

config = pulumi.Config()
vpc_name = config.get("vpcName")
if vpc_name is None:
    vpc_name = "huaweicloud_vpc"
vpc_cidr = config.get("vpcCidr")
if vpc_cidr is None:
    vpc_cidr = "192.168.0.0/16"
vpc = huaweicloud.vpc.Vpc("vpc", cidr=vpc_cidr)
vpc_with_tags = huaweicloud.vpc.Vpc("vpcWithTags",
    cidr=vpc_cidr,
    tags={
        "foo": "bar",
        "key": "value",
    })
import * as pulumi from "@pulumi/pulumi";
import * as pulumi from "@huaweicloudos/pulumi";

const config = new pulumi.Config();
const vpcName = config.get("vpcName") || "huaweicloud_vpc";
const vpcCidr = config.get("vpcCidr") || "192.168.0.0/16";
const vpc = new huaweicloud.vpc.Vpc("vpc", {cidr: vpcCidr});
const vpcWithTags = new huaweicloud.vpc.Vpc("vpcWithTags", {
    cidr: vpcCidr,
    tags: {
        foo: "bar",
        key: "value",
    },
});
configuration:
  vpcName:
    type: string
    default: huaweicloud_vpc
  vpcCidr:
    type: string
    default: 192.168.0.0/16
resources:
  vpc:
    type: huaweicloud:Vpc:Vpc
    properties:
      cidr: ${vpcCidr}
  vpcWithTags:
    type: huaweicloud:Vpc:Vpc
    properties:
      cidr: ${vpcCidr}
      tags:
        foo: bar
        key: value

Create Vpc Resource {#create}

new Vpc(name: string, args: VpcArgs, opts?: CustomResourceOptions);
@overload
def Vpc(resource_name: str,
        opts: Optional[ResourceOptions] = None,
        cidr: Optional[str] = None,
        description: Optional[str] = None,
        enterprise_project_id: Optional[str] = None,
        name: Optional[str] = None,
        region: Optional[str] = None,
        secondary_cidr: Optional[str] = None,
        tags: Optional[Mapping[str, str]] = None)
@overload
def Vpc(resource_name: str,
        args: VpcArgs,
        opts: Optional[ResourceOptions] = 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: huaweicloud:Vpc:Vpc
properties: # The arguments to resource properties.
options: # 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.
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.

Vpc Resource Properties {#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:

Cidr string

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

Description string

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

EnterpriseProjectId string

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

Name string

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

Region string

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

SecondaryCidr string

Specifies the secondary CIDR block of the VPC.

Tags Dictionary<string, string>

Specifies the key/value pairs to associate with the VPC.

Cidr string

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

Description string

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

EnterpriseProjectId string

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

Name string

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

Region string

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

SecondaryCidr string

Specifies the secondary CIDR block of the VPC.

Tags map[string]string

Specifies the key/value pairs to associate with the VPC.

cidr String

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description String

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterpriseProjectId String

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name String

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region String

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

secondaryCidr String

Specifies the secondary CIDR block of the VPC.

tags Map<String,String>

Specifies the key/value pairs to associate with the VPC.

cidr string

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description string

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterpriseProjectId string

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name string

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region string

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

secondaryCidr string

Specifies the secondary CIDR block of the VPC.

tags {[key: string]: string}

Specifies the key/value pairs to associate with the VPC.

cidr str

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description str

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterprise_project_id str

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name str

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region str

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

secondary_cidr str

Specifies the secondary CIDR block of the VPC.

tags Mapping[str, str]

Specifies the key/value pairs to associate with the VPC.

cidr String

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description String

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterpriseProjectId String

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name String

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region String

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

secondaryCidr String

Specifies the secondary CIDR block of the VPC.

tags Map<String>

Specifies the key/value pairs to associate with the VPC.

Outputs

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

Id string

The provider-assigned unique ID for this managed resource.

Routes List<VpcRoute>

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

Status string

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

Id string

The provider-assigned unique ID for this managed resource.

Routes []VpcRoute

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

Status string

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

id String

The provider-assigned unique ID for this managed resource.

routes List<Route>

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

status String

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

id string

The provider-assigned unique ID for this managed resource.

routes VpcRoute[]

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

status string

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

id str

The provider-assigned unique ID for this managed resource.

routes VpcRoute]

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

status str

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

id String

The provider-assigned unique ID for this managed resource.

routes List<Property Map>

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

status String

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

Look up Existing Vpc Resource {#look-up}

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: Optional[str] = None,
        description: Optional[str] = None,
        enterprise_project_id: Optional[str] = None,
        name: Optional[str] = None,
        region: Optional[str] = None,
        routes: Optional[Sequence[_vpc.VpcRouteArgs]] = None,
        secondary_cidr: Optional[str] = None,
        status: Optional[str] = None,
        tags: Optional[Mapping[str, 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:
Cidr string

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

Description string

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

EnterpriseProjectId string

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

Name string

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

Region string

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

Routes List<VpcRouteArgs>

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

SecondaryCidr string

Specifies the secondary CIDR block of the VPC.

Status string

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

Tags Dictionary<string, string>

Specifies the key/value pairs to associate with the VPC.

Cidr string

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

Description string

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

EnterpriseProjectId string

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

Name string

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

Region string

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

Routes []VpcRouteArgs

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

SecondaryCidr string

Specifies the secondary CIDR block of the VPC.

Status string

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

Tags map[string]string

Specifies the key/value pairs to associate with the VPC.

cidr String

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description String

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterpriseProjectId String

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name String

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region String

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

routes List<RouteArgs>

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

secondaryCidr String

Specifies the secondary CIDR block of the VPC.

status String

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

tags Map<String,String>

Specifies the key/value pairs to associate with the VPC.

cidr string

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description string

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterpriseProjectId string

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name string

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region string

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

routes VpcRouteArgs[]

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

secondaryCidr string

Specifies the secondary CIDR block of the VPC.

status string

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

tags {[key: string]: string}

Specifies the key/value pairs to associate with the VPC.

cidr str

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description str

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterprise_project_id str

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name str

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region str

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

routes VpcRouteArgs]

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

secondary_cidr str

Specifies the secondary CIDR block of the VPC.

status str

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

tags Mapping[str, str]

Specifies the key/value pairs to associate with the VPC.

cidr String

Specifies the range of available subnets in the VPC. The value ranges from 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, or 192.168.0.0/16 to 192.168.255.0/24.

description String

Specifies supplementary information about the VPC. The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).

enterpriseProjectId String

Specifies the enterprise project id of the VPC. Changing this creates a new VPC resource.

name String

Specifies the name of the VPC. The name must be unique for a tenant. The value is a string of no more than 64 characters and can contain digits, letters, underscores (_), and hyphens (-).

region String

Specifies the region in which to create the VPC. If omitted, the provider-level region will be used. Changing this creates a new VPC resource.

routes List<Property Map>

Deprecated:

use huaweicloud_vpc_route_table data source to get all routes

secondaryCidr String

Specifies the secondary CIDR block of the VPC.

status String

The current status of the VPC. Possible values are as follows: CREATING, OK or ERROR.

tags Map<String>

Specifies the key/value pairs to associate with the VPC.

Supporting Types

VpcRoute

Destination string
Nexthop string
Destination string
Nexthop string
destination String
nexthop String
destination string
nexthop string
destination String
nexthop String

Import

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

 $ pulumi import huaweicloud:Vpc/vpc:Vpc vpc_v1 7117d38e-4c8f-4624-a505-bd96b97d024c

Note that the imported state may not be identical to your resource definition when secondary_cidr was set. You you can ignore changes as below. resource "huaweicloud_vpc" "vpc_v1" {

...

lifecycle {

ignore_changes = [ secondary_cidr ]

} }

Package Details

Repository
https://github.com/huaweicloud/pulumi-huaweicloud
License
Apache-2.0
Notes

This Pulumi package is based on the huaweicloud Terraform Provider.