github.com/candidpartners/terraform@v0.9.5-0.20171005231213-29f5f88820f6/examples/alicloud-ecs-zone-type/main.tf (about) 1 data "alicloud_instance_types" "1c2g" { 2 cpu_core_count = 1 3 memory_size = 2 4 instance_type_family = "ecs.n1" 5 } 6 7 data "alicloud_zones" "default" { 8 "available_instance_type"= "${data.alicloud_instance_types.1c2g.instance_types.0.id}" 9 "available_disk_category"= "${var.disk_category}" 10 } 11 12 resource "alicloud_security_group" "group" { 13 name = "${var.short_name}" 14 description = "New security group" 15 } 16 17 resource "alicloud_security_group_rule" "http-in" { 18 type = "ingress" 19 ip_protocol = "tcp" 20 nic_type = "internet" 21 policy = "accept" 22 port_range = "80/80" 23 priority = 1 24 security_group_id = "${alicloud_security_group.group.id}" 25 cidr_ip = "0.0.0.0/0" 26 } 27 28 resource "alicloud_security_group_rule" "https-in" { 29 type = "ingress" 30 ip_protocol = "tcp" 31 nic_type = "internet" 32 policy = "accept" 33 port_range = "443/443" 34 priority = 1 35 security_group_id = "${alicloud_security_group.group.id}" 36 cidr_ip = "0.0.0.0/0" 37 } 38 39 resource "alicloud_security_group_rule" "ssh-in" { 40 type = "ingress" 41 ip_protocol = "tcp" 42 nic_type = "internet" 43 policy = "accept" 44 port_range = "22/22" 45 priority = 1 46 security_group_id = "${alicloud_security_group.group.id}" 47 cidr_ip = "0.0.0.0/0" 48 } 49 50 resource "alicloud_instance" "instance" { 51 instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" 52 host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" 53 image_id = "${var.image_id}" 54 instance_type = "${data.alicloud_instance_types.1c2g.instance_types.0.id}" 55 count = "${var.count}" 56 availability_zone = "${data.alicloud_zones.default.zones.0.id}" 57 security_groups = ["${alicloud_security_group.group.*.id}"] 58 59 internet_charge_type = "${var.internet_charge_type}" 60 internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}" 61 62 io_optimized = "${var.io_optimized}" 63 64 password = "${var.ecs_password}" 65 66 instance_charge_type = "PostPaid" 67 system_disk_category = "${var.disk_category}" 68 69 70 tags { 71 role = "${var.role}" 72 dc = "${var.datacenter}" 73 } 74 75 }