github.com/candidpartners/terraform@v0.9.5-0.20171005231213-29f5f88820f6/examples/alicloud-vpc-route-entry/main.tf (about) 1 resource "alicloud_vpc" "default" { 2 name = "tf_vpc" 3 cidr_block = "${var.vpc_cidr}" 4 } 5 6 resource "alicloud_vswitch" "default" { 7 vpc_id = "${alicloud_vpc.default.id}" 8 cidr_block = "${var.vswitch_cidr}" 9 availability_zone = "${var.zone_id}" 10 } 11 12 resource "alicloud_route_entry" "default" { 13 router_id = "${alicloud_vpc.default.router_id}" 14 route_table_id = "${alicloud_vpc.default.router_table_id}" 15 destination_cidrblock = "${var.entry_cidr}" 16 nexthop_type = "Instance" 17 nexthop_id = "${alicloud_instance.snat.id}" 18 } 19 20 resource "alicloud_security_group" "sg" { 21 name = "tf_sg" 22 description = "tf_sg" 23 vpc_id = "${alicloud_vpc.default.id}" 24 } 25 26 resource "alicloud_security_group_rule" "ssh-in" { 27 type = "ingress" 28 ip_protocol = "tcp" 29 nic_type = "intranet" 30 policy = "${var.rule_policy}" 31 port_range = "22/22" 32 priority = 1 33 security_group_id = "${alicloud_security_group.sg.id}" 34 cidr_ip = "0.0.0.0/0" 35 } 36 37 resource "alicloud_security_group_rule" "http-in" { 38 type = "ingress" 39 ip_protocol = "tcp" 40 nic_type = "internet" 41 policy = "accept" 42 port_range = "80/80" 43 priority = 1 44 security_group_id = "${alicloud_security_group.sg.id}" 45 cidr_ip = "0.0.0.0/0" 46 } 47 48 resource "alicloud_security_group_rule" "https-in" { 49 type = "ingress" 50 ip_protocol = "tcp" 51 nic_type = "internet" 52 policy = "accept" 53 port_range = "443/443" 54 priority = 1 55 security_group_id = "${alicloud_security_group.sg.id}" 56 cidr_ip = "0.0.0.0/0" 57 } 58 59 resource "alicloud_instance" "snat" { 60 # cn-beijing 61 availability_zone = "${var.zone_id}" 62 security_groups = ["${alicloud_security_group.sg.id}"] 63 64 vswitch_id = "${alicloud_vswitch.default.id}" 65 allocate_public_ip = true 66 67 # series II 68 instance_charge_type = "PostPaid" 69 instance_type = "${var.instance_type}" 70 internet_charge_type = "${var.internet_charge_type}" 71 internet_max_bandwidth_out = 5 72 io_optimized = "${var.io_optimized}" 73 74 system_disk_category = "cloud_efficiency" 75 image_id = "${var.image_id}" 76 instance_name = "tf_snat" 77 }