2017-01-19 15:08:56 +01:00
|
|
|
|
|
|
|
resource "alicloud_vpc" "default" {
|
|
|
|
name = "tf-vpc"
|
|
|
|
cidr_block = "${var.vpc_cidr}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_vswitch" "vsw" {
|
|
|
|
vpc_id = "${alicloud_vpc.default.id}"
|
|
|
|
cidr_block = "${var.vswitch_cidr}"
|
|
|
|
availability_zone = "${var.zone}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_security_group" "sg" {
|
2017-03-15 16:18:11 +01:00
|
|
|
name = "tf-sg"
|
|
|
|
description = "sg"
|
|
|
|
vpc_id = "${alicloud_vpc.default.id}"
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_instance" "website" {
|
2017-03-15 16:18:11 +01:00
|
|
|
# cn-beijing
|
|
|
|
availability_zone = "${var.zone}"
|
|
|
|
vswitch_id = "${alicloud_vswitch.vsw.id}"
|
|
|
|
image_id = "${var.image}"
|
|
|
|
|
|
|
|
# series II
|
|
|
|
instance_type = "${var.ecs_type}"
|
|
|
|
io_optimized = "optimized"
|
|
|
|
system_disk_category = "cloud_efficiency"
|
|
|
|
|
|
|
|
internet_charge_type = "PayByTraffic"
|
|
|
|
internet_max_bandwidth_out = 5
|
|
|
|
allocate_public_ip = true
|
|
|
|
security_groups = ["${alicloud_security_group.sg.id}"]
|
|
|
|
instance_name = "test_foo"
|
|
|
|
|
|
|
|
user_data = "${file("userdata.sh")}"
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|