github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/examples/alicloud-ecs-image/main.tf (about) 1 data "alicloud_images" "ecs_image" { 2 most_recent = "${var.most_recent}" 3 owners = "${var.image_owners}" 4 name_regex = "${var.name_regex}" 5 } 6 7 resource "alicloud_security_group" "group" { 8 name = "${var.short_name}" 9 description = "New security group" 10 } 11 12 13 resource "alicloud_disk" "disk" { 14 availability_zone = "${var.availability_zones}" 15 category = "${var.disk_category}" 16 size = "${var.disk_size}" 17 count = "${var.count}" 18 } 19 20 resource "alicloud_instance" "instance" { 21 instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" 22 host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" 23 image_id = "${data.alicloud_images.ecs_image.images.0.id}" 24 instance_type = "${var.ecs_type}" 25 count = "${var.count}" 26 availability_zone = "${var.availability_zones}" 27 security_groups = ["${alicloud_security_group.group.*.id}"] 28 29 internet_charge_type = "${var.internet_charge_type}" 30 internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}" 31 32 io_optimized = "${var.io_optimized}" 33 34 password = "${var.ecs_password}" 35 36 allocate_public_ip = "${var.allocate_public_ip}" 37 38 instance_charge_type = "PostPaid" 39 system_disk_category = "cloud_efficiency" 40 41 42 tags { 43 role = "${var.role}" 44 dc = "${var.datacenter}" 45 } 46 47 } 48 49 resource "alicloud_disk_attachment" "instance-attachment" { 50 count = "${var.count}" 51 disk_id = "${element(alicloud_disk.disk.*.id, count.index)}" 52 instance_id = "${element(alicloud_instance.instance.*.id, count.index)}" 53 device_name = "${var.device_name}" 54 } 55