alicloud_route_entry
更新时间:
Provides a Route Entry resource. A Route Entry represents a route item of one VPC Route Table.
For information about Route Entry and how to use it, see What is Route Entry.
-> NOTE: Available since v0.1.0.
Example Usage
Basic Usage
variable "name" {
default = "terraform-example"
}
data "alicloud_zones" "default" {
available_disk_category = "cloud_efficiency"
available_resource_creation = "VSwitch"
}
data "alicloud_images" "default" {
most_recent = true
owners = "system"
}
data "alicloud_instance_types" "default" {
availability_zone = data.alicloud_zones.default.zones.0.id
image_id = data.alicloud_images.default.images.0.id
}
resource "alicloud_vpc" "default" {
vpc_name = var.name
cidr_block = "192.168.0.0/16"
}
resource "alicloud_vswitch" "default" {
vswitch_name = var.name
vpc_id = alicloud_vpc.default.id
cidr_block = "192.168.192.0/24"
zone_id = data.alicloud_zones.default.zones.0.id
}
resource "alicloud_security_group" "default" {
name = var.name
vpc_id = alicloud_vpc.default.id
}
resource "alicloud_instance" "default" {
image_id = data.alicloud_images.default.images.0.id
instance_type = data.alicloud_instance_types.default.instance_types.0.id
security_groups = alicloud_security_group.default.*.id
internet_charge_type = "PayByTraffic"
internet_max_bandwidth_out = "10"
availability_zone = data.alicloud_instance_types.default.instance_types.0.availability_zones.0
instance_charge_type = "PostPaid"
system_disk_category = "cloud_efficiency"
vswitch_id = alicloud_vswitch.default.id
instance_name = var.name
}
resource "alicloud_route_entry" "foo" {
route_table_id = alicloud_vpc.default.route_table_id
destination_cidrblock = "172.11.1.1/32"
nexthop_type = "Instance"
nexthop_id = alicloud_instance.default.id
}
Module Support
You can use to the existing vpc module to create a VPC, several VSwitches and add several route entries one-click.
Argument Reference
The following arguments are supported:
route_table_id
- (Required, ForceNew) The ID of the Route Table.destination_cidrblock
- (Optional, ForceNew) The destination CIDR block of the custom route entry.nexthop_type
- (Optional, ForceNew) The type of Next Hop. Valid values:Instance
: An Elastic Compute Service (ECS) instance.HaVip
: A high-availability virtual IP address (HAVIP).RouterInterface
: A router interface.NetworkInterface
: An elastic network interface (ENI).VpnGateway
: A VPN Gateway.IPv6Gateway
: An IPv6 gateway.NatGateway
: A Nat Gateway.Attachment
: A transit router.VpcPeer
: A VPC Peering Connection.Ipv4Gateway
: An IPv4 gateway.GatewayEndpoint
: A gateway endpoint.Ecr
: A Express Connect Router (ECR).
nexthop_id
- (Optional, ForceNew) The ID of Next Hop.name
- (Optional, ForceNew, Available since v1.55.1) The name of the Route Entry. The name must be1
to128
characters in length, and cannot start withhttp://
orhttps://
.description
- (Optional, ForceNew, Available since v1.231.0) The description of the Route Entry. The description must be1
to256
characters in length, and cannot start withhttp://
orhttps://
.router_id
- (Deprecated) This argument has been deprecated. Please use other arguments to launch a custom route entry.
Attributes Reference
The following attributes are exported:
id
- The resource ID in terraform of Route Entry. It formats as<route_table_id>:<router_id>:<destination_cidrblock>:<nexthop_type>:<nexthop_id>
.
Import
$ terraform import alicloud_route_entry.example <route_table_id>:<router_id>:<destination_cidrblock>:<nexthop_type>:<nexthop_id>
文档内容是否对您有帮助?