alicloud_vswitch
更新时间:
Provides a VPC Vswitch resource. ## Module Support
You can use to the existing vpc module to create a VPC and several VSwitches one-click.
For information about VPC Vswitch and how to use it, see What is Vswitch.
-> NOTE: Available since v1.0.0.
Example Usage
Basic Usage
data "alicloud_zones" "foo" {
available_resource_creation = "VSwitch"
}
resource "alicloud_vpc" "foo" {
vpc_name = "terraform-example"
cidr_block = "172.16.0.0/12"
}
resource "alicloud_vswitch" "foo" {
vswitch_name = "terraform-example"
cidr_block = "172.16.0.0/21"
vpc_id = alicloud_vpc.foo.id
zone_id = data.alicloud_zones.foo.zones.0.id
}
data "alicloud_zones" "foo" {
available_resource_creation = "VSwitch"
}
resource "alicloud_vpc" "vpc" {
vpc_name = "terraform-example"
cidr_block = "172.16.0.0/12"
}
resource "alicloud_vpc_ipv4_cidr_block" "cidr_blocks" {
vpc_id = alicloud_vpc.vpc.id
secondary_cidr_block = "192.163.0.0/16"
}
resource "alicloud_vswitch" "island-nat" {
vpc_id = alicloud_vpc_ipv4_cidr_block.cidr_blocks.vpc_id
cidr_block = "172.16.0.0/21"
zone_id = data.alicloud_zones.foo.zones.0.id
vswitch_name = "terraform-example"
tags = {
BuiltBy = "example_value"
cnm_version = "example_value"
Environment = "example_value"
ManagedBy = "example_value"
}
}
Create a switch associated with the additional network segment
data "alicloud_zones" "foo" {
available_resource_creation = "VSwitch"
}
resource "alicloud_vpc" "foo" {
vpc_name = "terraform-example"
cidr_block = "172.16.0.0/12"
}
resource "alicloud_vpc_ipv4_cidr_block" "foo" {
vpc_id = alicloud_vpc.foo.id
secondary_cidr_block = "192.163.0.0/16"
}
resource "alicloud_vswitch" "foo" {
vpc_id = alicloud_vpc_ipv4_cidr_block.foo.vpc_id
cidr_block = "192.163.0.0/24"
zone_id = data.alicloud_zones.foo.zones.0.id
}
Argument Reference
The following arguments are supported:
cidr_block- (Optional, ForceNew) The IPv4 CIDR block of the VSwitch. NOTE: From version 1.233.0, if you do not setis_default, or setis_defaulttofalse,cidr_blockis required.description- (Optional) The description of VSwitch.zone_id- (Optional, ForceNew, Available since v1.119.0) The AZ for the VSwitch. Note: Required for a VPC VSwitch.enable_ipv6- (Optional, Available since v1.201.0) Whether the IPv6 function is enabled in the switch. Value:true: enables IPv6.false(default): IPv6 is not enabled.
ipv6_cidr_block_mask- (Optional, Available since v1.201.0) The IPv6 CIDR block of the VSwitch.tags- (Optional, Map, Available since v1.55.3) The tags of VSwitch.vswitch_name- (Optional, Available since v1.119.0) The name of the VSwitch.vpc_id- (Optional, ForceNew) The VPC ID. NOTE: From version 1.233.0, if you do not setis_default, or setis_defaulttofalse,vpc_idis required.is_default- (Optional, Bool, Available since v1.233.0) Specifies whether to create the default VSwitch. Default value:false. Valid values:true: Creates a default vSwitch.false: Creates a vSwitch.
The following arguments will be discarded. Please use new fields as soon as possible:
name- (Deprecated since v1.119.0) Fieldnamehas been deprecated from provider version 1.119.0. New fieldvswitch_nameinstead.availability_zone- (Deprecated since v1.119.0) Fieldavailability_zonehas been deprecated from provider version 1.119.0. New fieldzone_idinstead.
Attributes Reference
The following attributes are exported:
id- The ID of the resource supplied above.create_time- The creation time of the VSwitch.ipv6_cidr_block- The IPv6 CIDR block of the VSwitch.status- The status of the resource.
Timeouts
The timeouts block allows you to specify timeouts for certain actions:
create- (Defaults to 5 mins) Used when create the Vswitch.delete- (Defaults to 5 mins) Used when delete the Vswitch.update- (Defaults to 5 mins) Used when update the Vswitch.
Import
VPC Vswitch can be imported using the id, e.g.
$ terraform import alicloud_vpc_vswitch.example <id>
该文章对您有帮助吗?