alicloud_vpc
Provides a VPC VPC resource.
A VPC instance creates a VPC. You can fully control your own VPC, such as selecting IP address ranges, configuring routing tables, and gateways. You can use Alibaba cloud resources such as cloud servers, apsaradb for RDS, and load balancer in your own VPC.
-> NOTE: This resource will auto build a router and a route table while it uses alicloud_vpc to build a vpc resource.
-> NOTE: Available since v1.0.0.
Module Support
You can use the existing vpc module to create a VPC and several VSwitches one-click.
For information about VPC VPC and how to use it, see What is VPC.
Example Usage
Basic Usage
variable "name" {
default = "terraform-example"
}
resource "alicloud_vpc" "default" {
description = "example description"
cidr_block = "10.0.0.0/8"
vpc_name = var.name
enable_ipv6 = true
}
Need more examples? VIEW MORE EXAMPLES
Argument Reference
The following arguments are supported:
-
is_default- (Optional, ForceNew, Computed) Specifies whether to create the default VPC in the specified region. Valid values:truefalse(default)
-> NOTE: When
is_defaultistrue, a region can contain only one default VPC and concurrent default VPC creation in the same region is not supported. After a default VPC is created, its CIDR block cannot be modified, but secondary IPv4 CIDR blocks can be added. A default VPC provides 300,000 private IP addresses for cloud resources and this quota cannot be increased. A router and route table are automatically created with the default VPC. Each default VPC supports up to three user CIDR blocks; if multiple user CIDR blocks overlap, the CIDR block with the shorter mask takes effect. -
cidr_block- (Optional, Computed) The CIDR block of the VPC.- You can specify one of the following CIDR blocks or their subsets as the primary IPv4 CIDR block of the VPC: 192.168.0.0/16, 172.16.0.0/12, and 10.0.0.0/8. These CIDR blocks are standard private CIDR blocks as defined by Request for Comments (RFC) documents. The subnet mask must be 8 to 28 bits in length.
- You can also use a custom CIDR block other than 100.64.0.0/10, 224.0.0.0/4, 127.0.0.0/8, 169.254.0.0/16, and their subnets as the primary IPv4 CIDR block of the VPC.
-
classic_link_enabled- (Optional, Deprecated since v1.286.0) The status of ClassicLink function. Field 'classic_link_enabled' has been deprecated from provider version 1.286.0. The underlying ClassicLink feature has been deprecated by Alibaba Cloud and this field will be removed in a future version. For more information, see the deprecated API references EnableVpcClassicLink and DisableVpcClassicLink. -
description- (Optional) The new description of the VPC. The description must be 1 to 256 characters in length, and cannot start withhttp://orhttps://. -
dns_hostname_status- (Optional, Computed, Available since v1.240.0) Whether to enable the DNS hostname feature. Valid values:ENABLED,DISABLED. -
dry_run- (Optional, Available since v1.119.0) Whether to PreCheck only this request. Value:true: The check request is sent without creating a VPC. Check items include whether required parameters, request format, and business restrictions are filled in. If the check does not pass, the corresponding error is returned. If the check passes, the error code 'DryRunOperation' is returned '.false(default): Sends a normal request, returns an HTTP 2xx status code and directly creates a VPC.
-
enable_ipv6- (Optional, Computed, Available since v1.119.0) Whether to enable the IPv6 network segment. Value:false(default): Not enabled.true: enabled.
-> NOTE: If you use the
alicloud_vpc_ipv6_cidr_blockresource to add an IPv6 CIDR block to the VPC, you do not need to setenable_ipv6. -
force_delete- (Optional, Available since v1.248.0) Force delete vpc or not. -
ipv4_cidr_mask- (Optional, Int, Available since v1.240.0) Allocate VPC from The IPAM address pool by entering a mask.-> NOTE: when you specify the IPAM address pool to create a VPC, enter at least one of the CidrBlock or Ipv4CidrMask parameters.
-
ipv4_ipam_pool_id- (Optional) The ID of the IP Address Manager (IPAM) pool that contains IPv4 addresses. -
ipv6_cidr_block- (Optional, ForceNew, Computed, Deprecated since v1.280.0) The IPv6 CIDR block of the default VPC. Please use the new resourcealicloud_vpc_ipv6_cidr_block.-> NOTE: When
EnableIpv6is set totrue, this parameter is required. -
ipv6_isp- (Optional, Computed, Deprecated since v1.280.0) The IPv6 address segment type of the VPC. Please use the new resourcealicloud_vpc_ipv6_cidr_block. Value:BGP(default): Alibaba Cloud BGP IPv6.ChinaMobile: China Mobile (single line).ChinaUnicom: China Unicom (single line).ChinaTelecom: China Telecom (single line).
-> NOTE: If a single-line bandwidth whitelist is enabled, this field can be set to
ChinaTelecom(China Telecom),ChinaUnicom(China Unicom), orChinaMobile(China Mobile). -
resource_group_id- (Optional, Computed, Available since v1.115) The ID of the resource group to which you want to move the resource.-> NOTE: You can use resource groups to facilitate resource grouping and permission management for an Alibaba Cloud. For more information, see What is resource management?
-
secondary_cidr_blocks- (Optional, Computed, List, Deprecated since v1.185.0) Field 'secondary_cidr_blocks' has been deprecated from provider version 1.185.0 and it will be removed in the future version. Please use the new resource 'alicloud_vpc_ipv4_cidr_block'.secondary_cidr_blocksattributes andalicloud_vpc_ipv4_cidr_blockresource cannot be used at the same time. -
system_route_table_description- (Optional, Computed) The description of the route table. The description must be 1 to 256 characters in length, and cannot start withhttp://orhttps://. -
system_route_table_name- (Optional, Computed) The name of the route table. The name must be 1 to 128 characters in length and cannot start withhttp://orhttps://.-> NOTE: Because these fields are
Computed, removing them from your configuration does not clear the remote route table description or name. Terraform simply accepts the existing service value, preventing a persistent diff when the attribute is omitted from HCL. -
system_route_table_route_propagation_enable- (Optional, Computed, Available since v1.248.0) Whether the system route table receives propagation routes. -
tags- (Optional, Map, Available since v1.55.3) The tags of Vpc. -
user_cidrs- (Optional, ForceNew, Computed, List, Available since v1.119.0) A list of user CIDRs. Up to3CIDR blocks can be specified. -
vpc_name- (Optional, Computed, Available since v1.119.0) The new name of the VPC. The name must be 1 to 128 characters in length and cannot start withhttp://orhttps://.
The following arguments will be discarded. Please use new fields as soon as possible:
name- (Deprecated since v1.119.0). Field 'name' has been deprecated from provider version 1.119.0. New field 'vpc_name' instead.router_table_id- (Deprecated since v1.227.1). Field 'router_table_id' has been deprecated from provider version 1.227.1. New field 'route_table_id' instead.secondary_cidr_blocks- (Deprecated since v1.185.0) Field 'secondary_cidr_blocks' has been deprecated from provider version 1.185.0 and it will be removed in the future version. Please use the new resource 'alicloud_vpc_ipv4_cidr_block'.secondary_cidr_blocksattributes andalicloud_vpc_ipv4_cidr_blockresource cannot be used at the same time.secondary_cidr_mask- (Deprecated since v1.248.0) Field 'secondary_cidr_mask' has been deprecated from provider version 1.248.0. New resource 'alicloud_vpc_ipv4_cidr_block' instead.
Attributes Reference
The following attributes are exported:
id- The ID of the resource supplied above.create_time- The creation time of the VPC.ipv6_cidr_blocks- The IPv6 CIDR block information of the VPC.ipv6_cidr_block- The IPv6 CIDR block of the VPC.ipv6_isp- Valid values: BGP (default): Alibaba Cloud BGP IPv6.
is_default- Specifies whether to create the default VPC in the specified region.region_id- The ID of the region where the VPC is located.route_table_id- The ID of the system route table.router_id- The ID of the VRouter.status- The status of the VPC.Pending: The VPC is being configured.Available: The VPC is available.
Timeouts
The timeouts block allows you to specify timeouts for certain actions:
create- (Defaults to 10 mins) Used when create the VPC.delete- (Defaults to 5 mins) Used when delete the VPC.update- (Defaults to 5 mins) Used when update the VPC.
Import
VPC VPC can be imported using the id, e.g.
$ terraform import alicloud_vpc.example <id>