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