diff --git a/examples/ecs-image/README.md b/examples/ecs-image/README.md new file mode 100644 index 00000000000..a6a76d8e5ac --- /dev/null +++ b/examples/ecs-image/README.md @@ -0,0 +1,27 @@ +### ECS Example + +The example gains image info and use it to launche ECS instance, disk, and attached the disk on ECS. the count parameter in variables.tf can let you gain specify image and use it to create specify number ECS instances. + +### Get up and running + +* Planning phase + + terraform plan + var.availability_zones + Enter a value: {var.availability_zones} /*cn-beijing-b*/ + var.datacenter + Enter a value: {datacenter} + .... + +* Apply phase + + terraform apply + var.availability_zones + Enter a value: {var.availability_zones} /*cn-beijing-b*/ + var.datacenter + Enter a value: {datacenter} + .... + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs-image/main.tf b/examples/ecs-image/main.tf new file mode 100644 index 00000000000..743e6b9e1d3 --- /dev/null +++ b/examples/ecs-image/main.tf @@ -0,0 +1,55 @@ +data "alicloud_images" "ecs_image" { + most_recent = "${var.most_recent}" + owners = "${var.image_owners}" + name_regex = "${var.name_regex}" +} + +resource "alicloud_security_group" "group" { + name = "${var.short_name}" + description = "New security group" +} + + +resource "alicloud_disk" "disk" { + availability_zone = "${var.availability_zones}" + category = "${var.disk_category}" + size = "${var.disk_size}" + count = "${var.count}" +} + +resource "alicloud_instance" "instance" { + instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + image_id = "${data.alicloud_images.ecs_image.images.0.id}" + instance_type = "${var.ecs_type}" + count = "${var.count}" + availability_zone = "${var.availability_zones}" + security_groups = ["${alicloud_security_group.group.*.id}"] + + internet_charge_type = "${var.internet_charge_type}" + internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}" + + io_optimized = "${var.io_optimized}" + + password = "${var.ecs_password}" + + allocate_public_ip = "${var.allocate_public_ip}" + + instance_charge_type = "PostPaid" + system_disk_category = "cloud_efficiency" + + + tags { + role = "${var.role}" + dc = "${var.datacenter}" + } + +} + +resource "alicloud_disk_attachment" "instance-attachment" { + count = "${var.count}" + disk_id = "${element(alicloud_disk.disk.*.id, count.index)}" + instance_id = "${element(alicloud_instance.instance.*.id, count.index)}" + device_name = "${var.device_name}" +} + diff --git a/examples/ecs-image/outputs.tf b/examples/ecs-image/outputs.tf new file mode 100644 index 00000000000..104f2389fc3 --- /dev/null +++ b/examples/ecs-image/outputs.tf @@ -0,0 +1,15 @@ +output "hostname_list" { + value = "${join(",", alicloud_instance.instance.*.instance_name)}" +} + +output "ecs_ids" { + value = "${join(",", alicloud_instance.instance.*.id)}" +} + +output "ecs_public_ip" { + value = "${join(",", alicloud_instance.instance.*.public_ip)}" +} + +output "tags" { + value = "${jsonencode(alicloud_instance.instance.tags)}" +} \ No newline at end of file diff --git a/examples/ecs-image/variables.tf b/examples/ecs-image/variables.tf new file mode 100644 index 00000000000..35007e8c80c --- /dev/null +++ b/examples/ecs-image/variables.tf @@ -0,0 +1,57 @@ +variable "count" { + default = "1" +} +variable "count_format" { + default = "%02d" +} +variable "most_recent" { + default = true +} + +variable "image_owners" { + default = "" +} + +variable "name_regex" { + default = "^centos_6\\w{1,5}[64].*" +} + +variable "role" { + default = "work" +} +variable "datacenter" { + default = "beijing" +} +variable "short_name" { + default = "hi" +} +variable "ecs_type" { + default = "ecs.n1.small" +} +variable "ecs_password" { + default = "Test12345" +} +variable "availability_zones" { + default = "cn-beijing-b" +} +variable "allocate_public_ip" { + default = true +} +variable "internet_charge_type" { + default = "PayByTraffic" +} +variable "internet_max_bandwidth_out" { + default = 5 +} +variable "io_optimized" { + default = "optimized" +} +variable "disk_category" { + default = "cloud_ssd" +} +variable "disk_size" { + default = "40" +} +variable "device_name" { + default = "/dev/xvdb" +} \ No newline at end of file diff --git a/examples/ecs-slb/README.md b/examples/ecs-slb/README.md new file mode 100644 index 00000000000..db4b4631e35 --- /dev/null +++ b/examples/ecs-slb/README.md @@ -0,0 +1,18 @@ +### ECS With SLB Example + +The example launches ECS, disk, and attached the disk on ECS. It also creates an SLB, and addition the ECS to backendServer. The variables.tf can let you create specify parameter instances, such as image_id, ecs_type etc. + +### Get up and running + +* Planning phase + + terraform plan + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs-slb/main.tf b/examples/ecs-slb/main.tf new file mode 100644 index 00000000000..fad5c776826 --- /dev/null +++ b/examples/ecs-slb/main.tf @@ -0,0 +1,53 @@ +resource "alicloud_security_group" "group" { + name = "${var.short_name}" + description = "New security group" +} + +resource "alicloud_instance" "instance" { + instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + image_id = "${var.image_id}" + instance_type = "${var.ecs_type}" + count = "${var.count}" + availability_zone = "${var.availability_zones}" + security_groups = ["${alicloud_security_group.group.*.id}"] + + internet_charge_type = "${var.internet_charge_type}" + internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}" + + io_optimized = "${var.io_optimized}" + + password = "${var.ecs_password}" + + allocate_public_ip = "${var.allocate_public_ip}" + + instance_charge_type = "PostPaid" + system_disk_category = "cloud_efficiency" + + + tags { + role = "${var.role}" + dc = "${var.datacenter}" + } + +} + +resource "alicloud_slb" "instance" { + name = "${var.slb_name}" + internet_charge_type = "${var.slb_internet_charge_type}" + internet = "${var.internet}" + + listener = [ + { + "instance_port" = "2111" + "lb_port" = "21" + "lb_protocol" = "tcp" + "bandwidth" = "5" + }] +} + + +resource "alicloud_slb_attachment" "default" { + slb_id = "${alicloud_slb.instance.id}" + instances = ["${alicloud_instance.instance.*.id}"] +} \ No newline at end of file diff --git a/examples/ecs-slb/outputs.tf b/examples/ecs-slb/outputs.tf new file mode 100644 index 00000000000..9c7d3800ee2 --- /dev/null +++ b/examples/ecs-slb/outputs.tf @@ -0,0 +1,20 @@ +output "slb_id" { + value = "${alicloud_slb.instance.id}" +} + +output "slbname" { + value = "${alicloud_slb.instance.name}" +} + +output "hostname_list" { + value = "${join(",", alicloud_instance.instance.*.instance_name)}" +} + +output "ecs_ids" { + value = "${join(",", alicloud_instance.instance.*.id)}" +} + +output "slb_backendserver" { + value = "${alicloud_slb_attachment.default.backend_servers}" +} + diff --git a/examples/ecs-slb/variables.tf b/examples/ecs-slb/variables.tf new file mode 100644 index 00000000000..20896631a2c --- /dev/null +++ b/examples/ecs-slb/variables.tf @@ -0,0 +1,58 @@ +variable "count" { + default = "1" +} +variable "count_format" { + default = "%02d" +} +variable "image_id" { + default = "ubuntu_140405_64_40G_cloudinit_20161115.vhd" +} + +variable "role" { + default = "worder" +} +variable "datacenter" { + default = "beijing" +} +variable "short_name" { + default = "hi" +} +variable "ecs_type" { + default = "ecs.n1.small" +} +variable "ecs_password" { + default = "Test12345" +} +variable "availability_zones" { + default = "cn-beijing-b" +} +variable "ssh_username" { + default = "root" +} + +variable "allocate_public_ip" { + default = true +} + +variable "internet_charge_type" { + default = "PayByTraffic" +} + +variable "slb_internet_charge_type" { + default = "paybytraffic" +} +variable "internet_max_bandwidth_out" { + default = 5 +} + +variable "io_optimized" { + default = "optimized" +} + +variable "slb_name" { + default = "slb_worder" +} + +variable "internet" { + default = true +} diff --git a/examples/ecs-special-sg/README.md b/examples/ecs-special-sg/README.md new file mode 100644 index 00000000000..6e9e482a9f3 --- /dev/null +++ b/examples/ecs-special-sg/README.md @@ -0,0 +1,20 @@ +### ECS With special SLB and SecurityGroup Example + +The example launches 6 ECS and create it on special SLB and securityGroup. +Also additional first and second instance to the SLB backend server. +The variables.tf can let you create specify parameter instances, such as image_id, ecs_type etc. + +### Get up and running + +* Planning phase + + terraform plan + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs-special-sg/main.tf b/examples/ecs-special-sg/main.tf new file mode 100644 index 00000000000..ba92486a6d2 --- /dev/null +++ b/examples/ecs-special-sg/main.tf @@ -0,0 +1,39 @@ +provider "alicloud" { + alias = "bj" + region = "cn-beijing" +} + +resource "alicloud_instance" "instance" { + provider = "alicloud.bj" + instance_name = "website-${format(var.count_format, count.index+1)}" + host_name = "website-${format(var.count_format, count.index+1)}" + image_id = "centos7u2_64_40G_cloudinit_20160728.raw" + instance_type = "ecs.s2.large" + count = "6" + availability_zone = "cn-beijing-b" + security_groups = "${var.security_groups}" + + internet_charge_type = "PayByBandwidth" + + io_optimized = "none" + + password = "${var.ecs_password}" + + allocate_public_ip = "false" + + instance_charge_type = "PostPaid" + system_disk_category = "cloud" + + + tags { + env = "prod" + product = "website" + dc = "beijing" + } + +} + +resource "alicloud_slb_attachment" "foo" { + slb_id = "${var.slb_id}" + instances = ["${alicloud_instance.instance.0.id}", "${alicloud_instance.instance.1.id}"] +} \ No newline at end of file diff --git a/examples/ecs-special-sg/outputs.tf b/examples/ecs-special-sg/outputs.tf new file mode 100644 index 00000000000..33cb4a7e8f1 --- /dev/null +++ b/examples/ecs-special-sg/outputs.tf @@ -0,0 +1,7 @@ +output "hostname_list" { + value = "${join(",", alicloud_instance.instance.*.instance_name)}" +} + +output "ecs_ids" { + value = "${join(",", alicloud_instance.instance.*.id)}" +} diff --git a/examples/ecs-special-sg/variables.tf b/examples/ecs-special-sg/variables.tf new file mode 100644 index 00000000000..694b8000fd2 --- /dev/null +++ b/examples/ecs-special-sg/variables.tf @@ -0,0 +1,17 @@ +variable "count" { + default = "6" +} +variable "count_format" { + default = "%02d" +} + +variable "security_groups" { + type = "list" + default = ["sg-2zecd09tw30jo1c7ekdi"] +} +variable "ecs_password" { + default = "Test12345" +} +variable "slb_id"{ + default = "lb-2zel5fjqk1qgmwud7t3xb" +} \ No newline at end of file diff --git a/examples/ecs-userdata/README.md b/examples/ecs-userdata/README.md new file mode 100644 index 00000000000..f58f16c0d9e --- /dev/null +++ b/examples/ecs-userdata/README.md @@ -0,0 +1,17 @@ +### ECS with UserData Example + +Pass shell scripts to Ecs Instance by user_data parameter. + +### Get up and running + +* Planning phase + + terraform plan + +* Apply phase + + terraform apply + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs-userdata/main.tf b/examples/ecs-userdata/main.tf new file mode 100644 index 00000000000..99376325f35 --- /dev/null +++ b/examples/ecs-userdata/main.tf @@ -0,0 +1,37 @@ + +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" { + name = "tf-sg" + description = "sg" + vpc_id = "${alicloud_vpc.default.id}" +} + +resource "alicloud_instance" "website" { + # 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")}" +} diff --git a/examples/ecs-userdata/outputs.tf b/examples/ecs-userdata/outputs.tf new file mode 100644 index 00000000000..7115e9247f9 --- /dev/null +++ b/examples/ecs-userdata/outputs.tf @@ -0,0 +1,7 @@ +output "hostname" { + value = "${alicloud_instance.website.instance_name}" +} + +output "ecs_id" { + value = "${alicloud_instance.website.id}" +} \ No newline at end of file diff --git a/examples/ecs-userdata/userdata.sh b/examples/ecs-userdata/userdata.sh new file mode 100644 index 00000000000..dba9b889144 --- /dev/null +++ b/examples/ecs-userdata/userdata.sh @@ -0,0 +1,6 @@ +#!/bin/bash -v +apt-get update -y +apt-get install -y nginx > /tmp/nginx.log + +cd / +mkdir -p alicloud/go \ No newline at end of file diff --git a/examples/ecs-userdata/variables.tf b/examples/ecs-userdata/variables.tf new file mode 100644 index 00000000000..d8809ad8383 --- /dev/null +++ b/examples/ecs-userdata/variables.tf @@ -0,0 +1,19 @@ +variable "vpc_cidr" { + default = "172.16.0.0/12" +} + +variable "vswitch_cidr" { + default = "172.16.0.0/21" +} + +variable "zone" { + default = "cn-beijing-b" +} + +variable "image" { + default = "ubuntu_140405_32_40G_cloudinit_20161115.vhd" +} + +variable "ecs_type" { + default = "ecs.n1.medium" +} \ No newline at end of file diff --git a/examples/ecs-vpc-cluster/README.md b/examples/ecs-vpc-cluster/README.md new file mode 100644 index 00000000000..62fec8cc0b4 --- /dev/null +++ b/examples/ecs-vpc-cluster/README.md @@ -0,0 +1,19 @@ +### VPC Cluster Example + +The example launches VPC cluster, include VPC, VSwitch, Nategateway, ECS, SecurityGroups. the example used the "module" to create instances. The variables.tf can let you create specify parameter instances, such as image_id, ecs_type, count etc. + +### Get up and running + +* Planning phase + + terraform plan + + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs-vpc-cluster/main.tf b/examples/ecs-vpc-cluster/main.tf new file mode 100644 index 00000000000..0ec8bf8a006 --- /dev/null +++ b/examples/ecs-vpc-cluster/main.tf @@ -0,0 +1,62 @@ +provider "alicloud" { + region = "${var.region}" +} + +module "vpc" { + availability_zones = "${var.availability_zones}" + source = "../alicloud-vpc" + short_name = "${var.short_name}" + region = "${var.region}" +} + +module "security-groups" { + source = "../alicloud-vpc-cluster-sg" + short_name = "${var.short_name}" + vpc_id = "${module.vpc.vpc_id}" +} + +module "control-nodes" { + source = "../alicloud-ecs-vpc" + count = "${var.control_count}" + role = "control" + datacenter = "${var.datacenter}" + ecs_type = "${var.control_ecs_type}" + ecs_password = "${var.ecs_password}" + disk_size = "${var.control_disk_size}" + ssh_username = "${var.ssh_username}" + short_name = "${var.short_name}" + availability_zones = "${module.vpc.availability_zones}" + security_groups = ["${module.security-groups.control_security_group}"] + vswitch_id = "${module.vpc.vswitch_ids}" + internet_charge_type = "${var.internet_charge_type}" +} + +module "edge-nodes" { + source = "../alicloud-ecs-vpc" + count = "${var.edge_count}" + role = "edge" + datacenter = "${var.datacenter}" + ecs_type = "${var.edge_ecs_type}" + ecs_password = "${var.ecs_password}" + ssh_username = "${var.ssh_username}" + short_name = "${var.short_name}" + availability_zones = "${module.vpc.availability_zones}" + security_groups = ["${module.security-groups.worker_security_group}"] + vswitch_id = "${module.vpc.vswitch_ids}" + internet_charge_type = "${var.internet_charge_type}" +} + +module "worker-nodes" { + source = "../alicloud-ecs-vpc" + count = "${var.worker_count}" + role = "worker" + datacenter = "${var.datacenter}" + ecs_type = "${var.worker_ecs_type}" + ecs_password = "${var.ecs_password}" + ssh_username = "${var.ssh_username}" + short_name = "${var.short_name}" + availability_zones = "${module.vpc.availability_zones}" + security_groups = ["${module.security-groups.worker_security_group}"] + vswitch_id = "${module.vpc.vswitch_ids}" + internet_charge_type = "${var.internet_charge_type}" +} \ No newline at end of file diff --git a/examples/ecs-vpc-cluster/variables.tf b/examples/ecs-vpc-cluster/variables.tf new file mode 100644 index 00000000000..7af61186240 --- /dev/null +++ b/examples/ecs-vpc-cluster/variables.tf @@ -0,0 +1,59 @@ +variable "ecs_password" { + default = "Test12345" +} + +variable "control_count" { + default = "3" +} +variable "control_count_format" { + default = "%02d" +} +variable "control_ecs_type" { + default = "ecs.n1.medium" +} +variable "control_disk_size" { + default = "100" +} + +variable "edge_count" { + default = "2" +} +variable "edge_count_format" { + default = "%02d" +} +variable "edge_ecs_type" { + default = "ecs.n1.small" +} + +variable "worker_count" { + default = "1" +} +variable "worker_count_format" { + default = "%03d" +} +variable "worker_ecs_type" { + default = "ecs.n1.small" +} + +variable "short_name" { + default = "ali" +} +variable "ssh_username" { + default = "root" +} + +variable "region" { + default = "cn-beijing" +} + +variable "availability_zones" { + default = "cn-beijing-c" +} + +variable "internet_charge_type" { + default = "" +} + +variable "datacenter" { + default = "beijing" +} \ No newline at end of file diff --git a/examples/ecs-vpc/README.md b/examples/ecs-vpc/README.md new file mode 100644 index 00000000000..bfc92c494c9 --- /dev/null +++ b/examples/ecs-vpc/README.md @@ -0,0 +1,31 @@ +### ECS In VPC Example + +The example launches ECS in VPC, vswitch_id parameter is the vswitch id from VPC. It also create disk, and attached the disk on ECS. The variables.tf can let you create specify parameter instances, such as image_id, ecs_type, count etc. + +### Get up and running + +* Planning phase + + terraform plan + var.availability_zones + Enter a value: {var.availability_zones} /*cn-beijing-b*/ + var.datacenter + Enter a value: {datacenter} + var.vswitch_id + Enter a value: {vswitch_id} + .... + +* Apply phase + + terraform apply + var.availability_zones + Enter a value: {var.availability_zones} /*cn-beijing-b*/ + var.datacenter + Enter a value: {datacenter} + var.vswitch_id + Enter a value: {vswitch_id} + .... + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs-vpc/main.tf b/examples/ecs-vpc/main.tf new file mode 100644 index 00000000000..a4283ccd99b --- /dev/null +++ b/examples/ecs-vpc/main.tf @@ -0,0 +1,45 @@ +resource "alicloud_disk" "disk" { + availability_zone = "${var.availability_zones}" + category = "${var.disk_category}" + size = "${var.disk_size}" + count = "${var.count}" +} + +resource "alicloud_instance" "instance" { + instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + image_id = "${var.image_id}" + instance_type = "${var.ecs_type}" + count = "${var.count}" + availability_zone = "${var.availability_zones}" + security_groups = ["${var.security_groups}"] + vswitch_id = "${var.vswitch_id}" + + internet_charge_type = "${var.internet_charge_type}" + internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}" + + io_optimized = "${var.io_optimized}" + + allocate_public_ip = "${var.allocate_public_ip}" + + password = "${var.ecs_password}" + + instance_charge_type = "${var.instance_charge_type}" + system_disk_category = "${var.system_disk_category}" + + + tags { + role = "${var.role}" + dc = "${var.datacenter}" + } + +} + +resource "alicloud_disk_attachment" "instance-attachment" { + count = "${var.count}" + disk_id = "${element(alicloud_disk.disk.*.id, count.index)}" + instance_id = "${element(alicloud_instance.instance.*.id, count.index)}" + device_name = "${var.device_name}" +} + + diff --git a/examples/ecs-vpc/outputs.tf b/examples/ecs-vpc/outputs.tf new file mode 100644 index 00000000000..d1b7c8a19db --- /dev/null +++ b/examples/ecs-vpc/outputs.tf @@ -0,0 +1,7 @@ +output "hostname_list" { + value = "${join(",", alicloud_instance.instance.*.instance_name)}" +} + +output "ecs_ids" { + value = "${join(",", alicloud_instance.instance.*.id)}" +} \ No newline at end of file diff --git a/examples/ecs-vpc/variables.tf b/examples/ecs-vpc/variables.tf new file mode 100644 index 00000000000..67664e42556 --- /dev/null +++ b/examples/ecs-vpc/variables.tf @@ -0,0 +1,67 @@ +variable "count" { + default = "1" +} +variable "count_format" { + default = "%02d" +} +variable "image_id" { + default = "ubuntu_140405_64_40G_cloudinit_20161115.vhd" +} + +variable "role" { +} +variable "datacenter" { +} +variable "short_name" { + default = "hi" +} +variable "ecs_type" { +} +variable "ecs_password" { +} +variable "availability_zones" { +} +variable "security_groups" { + type = "list" +} +variable "ssh_username" { + default = "root" +} + +//if instance_charge_type is "PrePaid", then must be set period, the value is 1 to 30, unit is month +variable "instance_charge_type" { + default = "PostPaid" +} + +variable "system_disk_category" { + default = "cloud_efficiency" +} + +variable "internet_charge_type" { + default = "PayByTraffic" +} +variable "internet_max_bandwidth_out" { + default = 5 +} + +variable "io_optimized" { + default = "optimized" +} + +variable "allocate_public_ip" { + default = true +} + +variable "disk_category" { + default = "cloud_ssd" +} +variable "disk_size" { + default = "40" +} +variable "device_name" { + default = "/dev/xvdb" +} + +variable "vswitch_id" { + default = "" +} \ No newline at end of file diff --git a/examples/ecs-zone-type/README.md b/examples/ecs-zone-type/README.md new file mode 100644 index 00000000000..6f0b4622183 --- /dev/null +++ b/examples/ecs-zone-type/README.md @@ -0,0 +1,19 @@ +### Ecs Instance Type Data Source Example + +The example launches Ecs instance type Data Resource. Then set ecs parameter instance_type refer to the Data Resource config above. + +### Get up and running + +* Planning phase + + terraform plan + + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs-zone-type/main.tf b/examples/ecs-zone-type/main.tf new file mode 100644 index 00000000000..c3c21bc9ae0 --- /dev/null +++ b/examples/ecs-zone-type/main.tf @@ -0,0 +1,42 @@ +data "alicloud_instance_types" "1c2g" { + cpu_core_count = 1 + memory_size = 2 + instance_type_family = "ecs.n1" +} + +data "alicloud_zones" "default" { + "available_instance_type"= "${data.alicloud_instance_types.4c8g.instance_types.0.id}" + "available_disk_category"= "${var.disk_category}" +} + +resource "alicloud_security_group" "group" { + name = "${var.short_name}" + description = "New security group" +} + +resource "alicloud_instance" "instance" { + instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + image_id = "${var.image_id}" + instance_type = "${data.alicloud_instance_types.1c2g.instance_types.0.id}" + count = "${var.count}" + availability_zone = "${data.alicloud_zones.default.zones.0.id}" + security_groups = ["${alicloud_security_group.group.*.id}"] + + internet_charge_type = "${var.internet_charge_type}" + internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}" + + io_optimized = "${var.io_optimized}" + + password = "${var.ecs_password}" + + instance_charge_type = "PostPaid" + system_disk_category = "${var.disk_category}" + + + tags { + role = "${var.role}" + dc = "${var.datacenter}" + } + +} diff --git a/examples/ecs-zone-type/outputs.tf b/examples/ecs-zone-type/outputs.tf new file mode 100644 index 00000000000..104f2389fc3 --- /dev/null +++ b/examples/ecs-zone-type/outputs.tf @@ -0,0 +1,15 @@ +output "hostname_list" { + value = "${join(",", alicloud_instance.instance.*.instance_name)}" +} + +output "ecs_ids" { + value = "${join(",", alicloud_instance.instance.*.id)}" +} + +output "ecs_public_ip" { + value = "${join(",", alicloud_instance.instance.*.public_ip)}" +} + +output "tags" { + value = "${jsonencode(alicloud_instance.instance.tags)}" +} \ No newline at end of file diff --git a/examples/ecs-zone-type/variables.tf b/examples/ecs-zone-type/variables.tf new file mode 100644 index 00000000000..1ba1cb5cc51 --- /dev/null +++ b/examples/ecs-zone-type/variables.tf @@ -0,0 +1,35 @@ +variable "count" { + default = "1" +} +variable "count_format" { + default = "%02d" +} + +variable "image_id" { + default = "ubuntu_140405_64_40G_cloudinit_20161115.vhd" +} + +variable "disk_category" { + default = "cloud_ssd" +} +variable "role" { + default = "work" +} +variable "datacenter" { + default = "beijing" +} +variable "short_name" { + default = "hi" +} +variable "ecs_password" { + default = "Test12345" +} +variable "internet_charge_type" { + default = "PayByTraffic" +} +variable "internet_max_bandwidth_out" { + default = 5 +} +variable "io_optimized" { + default = "optimized" +} \ No newline at end of file diff --git a/examples/ecs/README.md b/examples/ecs/README.md new file mode 100644 index 00000000000..88d2887a347 --- /dev/null +++ b/examples/ecs/README.md @@ -0,0 +1,27 @@ +### ECS Example + +The example launches ECS instance, disk, and attached the disk on ECS. the count parameter in variables.tf can let you create specify number ECS instances. + +### Get up and running + +* Planning phase + + terraform plan + var.availability_zones + Enter a value: {var.availability_zones} /*cn-beijing-b*/ + var.datacenter + Enter a value: {datacenter} + .... + +* Apply phase + + terraform apply + var.availability_zones + Enter a value: {var.availability_zones} /*cn-beijing-b*/ + var.datacenter + Enter a value: {datacenter} + .... + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/ecs/main.tf b/examples/ecs/main.tf new file mode 100644 index 00000000000..a6d39a059e6 --- /dev/null +++ b/examples/ecs/main.tf @@ -0,0 +1,49 @@ +resource "alicloud_security_group" "group" { + name = "${var.short_name}" + description = "New security group" +} + + +resource "alicloud_disk" "disk" { + availability_zone = "${var.availability_zones}" + category = "${var.disk_category}" + size = "${var.disk_size}" + count = "${var.count}" +} + +resource "alicloud_instance" "instance" { + instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}" + image_id = "${var.image_id}" + instance_type = "${var.ecs_type}" + count = "${var.count}" + availability_zone = "${var.availability_zones}" + security_groups = ["${alicloud_security_group.group.*.id}"] + + internet_charge_type = "${var.internet_charge_type}" + internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}" + + password = "${var.ecs_password}" + + allocate_public_ip = "${var.allocate_public_ip}" + + io_optimized = "${var.io_optimized}" + + instance_charge_type = "PostPaid" + system_disk_category = "cloud_efficiency" + + + tags { + role = "${var.role}" + dc = "${var.datacenter}" + } + +} + +resource "alicloud_disk_attachment" "instance-attachment" { + count = "${var.count}" + disk_id = "${element(alicloud_disk.disk.*.id, count.index)}" + instance_id = "${element(alicloud_instance.instance.*.id, count.index)}" + device_name = "${var.device_name}" +} + diff --git a/examples/ecs/outputs.tf b/examples/ecs/outputs.tf new file mode 100644 index 00000000000..104f2389fc3 --- /dev/null +++ b/examples/ecs/outputs.tf @@ -0,0 +1,15 @@ +output "hostname_list" { + value = "${join(",", alicloud_instance.instance.*.instance_name)}" +} + +output "ecs_ids" { + value = "${join(",", alicloud_instance.instance.*.id)}" +} + +output "ecs_public_ip" { + value = "${join(",", alicloud_instance.instance.*.public_ip)}" +} + +output "tags" { + value = "${jsonencode(alicloud_instance.instance.tags)}" +} \ No newline at end of file diff --git a/examples/ecs/variables.tf b/examples/ecs/variables.tf new file mode 100644 index 00000000000..c663f8dd3ed --- /dev/null +++ b/examples/ecs/variables.tf @@ -0,0 +1,51 @@ +variable "count" { + default = "1" +} +variable "count_format" { + default = "%02d" +} +variable "image_id" { + default = "ubuntu_140405_64_40G_cloudinit_20161115.vhd" +} + +variable "role" { + default = "work" +} +variable "datacenter" { + default = "beijing" +} +variable "short_name" { + default = "hi" +} +variable "ecs_type" { + default = "ecs.n1.small" +} +variable "ecs_password" { + default = "Test12345" +} +variable "availability_zones" { + default = "cn-beijing-b" +} +variable "allocate_public_ip" { + default = true +} +variable "internet_charge_type" { + default = "PayByTraffic" +} +variable "internet_max_bandwidth_out" { + default = 5 +} + +variable "io_optimized" { + default = "optimized" +} + +variable "disk_category" { + default = "cloud_ssd" +} +variable "disk_size" { + default = "40" +} +variable "device_name" { + default = "/dev/xvdb" +} \ No newline at end of file diff --git a/examples/security-group-rule/main.tf b/examples/security-group-rule/main.tf new file mode 100644 index 00000000000..706ee08630c --- /dev/null +++ b/examples/security-group-rule/main.tf @@ -0,0 +1,14 @@ +resource "alicloud_security_group" "default" { + name = "${var.security_group_name}" +} + +resource "alicloud_security_group_rule" "allow_all_tcp" { + type = "ingress" + ip_protocol = "tcp" + nic_type = "${var.nic_type}" + policy = "accept" + port_range = "1/65535" + priority = 1 + security_group_id = "${alicloud_security_group.default.id}" + cidr_ip = "0.0.0.0/0" +} \ No newline at end of file diff --git a/examples/security-group-rule/outputs.tf b/examples/security-group-rule/outputs.tf new file mode 100644 index 00000000000..79ab88b6db5 --- /dev/null +++ b/examples/security-group-rule/outputs.tf @@ -0,0 +1,15 @@ +output "rule_id" { + value = "${alicloud_security_group_rule.allow_all_tcp.id}" +} + +output "rule_type" { + value = "${alicloud_security_group_rule.allow_all_tcp.type}" +} + +output "port_range" { + value = "${alicloud_security_group_rule.allow_all_tcp.port_range}" +} + +output "ip_protocol" { + value = "${alicloud_security_group_rule.allow_all_tcp.ip_protocol}" +} \ No newline at end of file diff --git a/examples/security-group-rule/variables.tf b/examples/security-group-rule/variables.tf new file mode 100644 index 00000000000..91aa57d4b63 --- /dev/null +++ b/examples/security-group-rule/variables.tf @@ -0,0 +1,7 @@ +variable "security_group_name" { + default = "default-sg" +} + +variable "nic_type" { + default = "internet" +} \ No newline at end of file diff --git a/examples/security-group/README.md b/examples/security-group/README.md new file mode 100644 index 00000000000..b54db7ad256 --- /dev/null +++ b/examples/security-group/README.md @@ -0,0 +1,19 @@ +### SecurityGroup With Vpc Example + +The example create SecurityGroup for specify VPC. + +### Get up and running + +* Planning phase + + terraform plan + + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/security-group/main.tf b/examples/security-group/main.tf new file mode 100644 index 00000000000..afdf0577f2f --- /dev/null +++ b/examples/security-group/main.tf @@ -0,0 +1,5 @@ +resource "alicloud_security_group" "group" { + name = "${var.short_name}" + description = "New security group" + vpc_id = "${var.vpc_id}" +} diff --git a/examples/security-group/outputs.tf b/examples/security-group/outputs.tf new file mode 100644 index 00000000000..bd67a462f4f --- /dev/null +++ b/examples/security-group/outputs.tf @@ -0,0 +1,3 @@ +output "security_group" { + value = "${alicloud_security_group.group.id}" +} \ No newline at end of file diff --git a/examples/security-group/variables.tf b/examples/security-group/variables.tf new file mode 100644 index 00000000000..e37d4e0d230 --- /dev/null +++ b/examples/security-group/variables.tf @@ -0,0 +1,4 @@ +variable "short_name" { +} +variable "vpc_id" { +} diff --git a/examples/slb-vpc/README.md b/examples/slb-vpc/README.md new file mode 100644 index 00000000000..809ed9589ca --- /dev/null +++ b/examples/slb-vpc/README.md @@ -0,0 +1,19 @@ +### SLB With VPC Example + +The example create SLB in special VPC, The variables.tf can let you create specify parameter instances, such as vpc_id, vswitch_id. + +### Get up and running + +* Planning phase + + terraform plan + + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/slb-vpc/main.tf b/examples/slb-vpc/main.tf new file mode 100644 index 00000000000..c54d16d0057 --- /dev/null +++ b/examples/slb-vpc/main.tf @@ -0,0 +1,27 @@ +resource "alicloud_vpc" "main" { + name = "${var.long_name}" + cidr_block = "${var.vpc_cidr}" +} + +resource "alicloud_vswitch" "main" { + vpc_id = "${alicloud_vpc.main.id}" + count = "${length(split(",", var.availability_zones))}" + cidr_block = "${lookup(var.cidr_blocks, "az${count.index}")}" + availability_zone = "${element(split(",", var.availability_zones), count.index)}" + depends_on = [ + "alicloud_vpc.main"] +} + +resource "alicloud_slb" "instance" { + name = "${var.name}" + vswitch_id = "${alicloud_vswitch.main.id}" + internet_charge_type = "${var.internet_charge_type}" + listener = [ + { + "instance_port" = "2111" + "lb_port" = "21" + "lb_protocol" = "tcp" + "bandwidth" = "5" + }] +} + diff --git a/examples/slb-vpc/outputs.tf b/examples/slb-vpc/outputs.tf new file mode 100644 index 00000000000..d8e1cc93e84 --- /dev/null +++ b/examples/slb-vpc/outputs.tf @@ -0,0 +1,7 @@ +output "slb_id" { + value = "${alicloud_slb.instance.id}" +} + +output "slbname" { + value = "${alicloud_slb.instance.name}" +} \ No newline at end of file diff --git a/examples/slb-vpc/variables.tf b/examples/slb-vpc/variables.tf new file mode 100644 index 00000000000..7e9f9d390e0 --- /dev/null +++ b/examples/slb-vpc/variables.tf @@ -0,0 +1,30 @@ +variable "availability_zones" { + default = "cn-beijing-c" +} + +variable "name" { + default = "slb_alicloud" +} + +variable "cidr_blocks" { + type = "map" + default = { + az0 = "10.1.1.0/24" + az1 = "10.1.2.0/24" + az2 = "10.1.3.0/24" + } +} + +variable "internet_charge_type" { + default = "paybytraffic" +} + +variable "long_name" { + default = "alicloud" +} +variable "vpc_cidr" { + default = "10.1.0.0/21" +} +variable "region" { + default = "cn-beijing" +} \ No newline at end of file diff --git a/examples/slb/README.md b/examples/slb/README.md new file mode 100644 index 00000000000..370476f13d3 Binary files /dev/null and b/examples/slb/README.md differ diff --git a/examples/slb/main.tf b/examples/slb/main.tf new file mode 100644 index 00000000000..67f5e0cf602 --- /dev/null +++ b/examples/slb/main.tf @@ -0,0 +1,25 @@ +resource "alicloud_slb" "instance" { + name = "${var.slb_name}" + internet_charge_type = "${var.internet_charge_type}" + internet = "${var.internet}" + + listener = [ + { + "instance_port" = "2111" + "lb_port" = "21" + "lb_protocol" = "tcp" + "bandwidth" = "5" + }, + { + "instance_port" = "8000" + "lb_port" = "80" + "lb_protocol" = "http" + "bandwidth" = "5" + }, + { + "instance_port" = "1611" + "lb_port" = "161" + "lb_protocol" = "udp" + "bandwidth" = "5" + }] +} diff --git a/examples/slb/outputs.tf b/examples/slb/outputs.tf new file mode 100644 index 00000000000..d8e1cc93e84 --- /dev/null +++ b/examples/slb/outputs.tf @@ -0,0 +1,7 @@ +output "slb_id" { + value = "${alicloud_slb.instance.id}" +} + +output "slbname" { + value = "${alicloud_slb.instance.name}" +} \ No newline at end of file diff --git a/examples/slb/variables.tf b/examples/slb/variables.tf new file mode 100644 index 00000000000..7a741b295c3 --- /dev/null +++ b/examples/slb/variables.tf @@ -0,0 +1,11 @@ +variable "slb_name" { + default = "slb_worder" +} + +variable "internet_charge_type" { + default = "paybytraffic" +} + +variable "internet" { + default = true +} diff --git a/examples/vpc-cluster-sg/README.md b/examples/vpc-cluster-sg/README.md new file mode 100644 index 00000000000..5ef00e5f630 --- /dev/null +++ b/examples/vpc-cluster-sg/README.md @@ -0,0 +1,19 @@ +### SecurityGroups With Vpc Example + +The example create SecurityGroups for specify VPC Clusters. + +### Get up and running + +* Planning phase + + terraform plan + + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/vpc-cluster-sg/main.tf b/examples/vpc-cluster-sg/main.tf new file mode 100644 index 00000000000..1e6575aeb9d --- /dev/null +++ b/examples/vpc-cluster-sg/main.tf @@ -0,0 +1,23 @@ +resource "alicloud_security_group" "default" { + name = "${var.short_name}-default" + description = "Default security group for VPC" + vpc_id = "${var.vpc_id}" +} + +resource "alicloud_security_group" "control" { + name = "${var.short_name}-control" + description = "Allow inboud traffic for control nodes" + vpc_id = "${var.vpc_id}" +} + +resource "alicloud_security_group" "edge" { + name = "${var.short_name}-edge" + description = "Allow inboud traffic for edge routing" + vpc_id = "${var.vpc_id}" +} + +resource "alicloud_security_group" "worker" { + name = "${var.short_name}-worker" + description = "Allow inboud traffic for worker nodes" + vpc_id = "${var.vpc_id}" +} diff --git a/examples/vpc-cluster-sg/outputs.tf b/examples/vpc-cluster-sg/outputs.tf new file mode 100644 index 00000000000..f2e6408069a --- /dev/null +++ b/examples/vpc-cluster-sg/outputs.tf @@ -0,0 +1,15 @@ +output "default_security_group" { + value = "${alicloud_security_group.default.id}" +} + +output "edge_security_group" { + value = "${alicloud_security_group.edge.id}" +} + +output "control_security_group" { + value = "${alicloud_security_group.control.id}" +} + +output "worker_security_group" { + value = "${alicloud_security_group.worker.id}" +} diff --git a/examples/vpc-cluster-sg/variables.tf b/examples/vpc-cluster-sg/variables.tf new file mode 100644 index 00000000000..e37d4e0d230 --- /dev/null +++ b/examples/vpc-cluster-sg/variables.tf @@ -0,0 +1,4 @@ +variable "short_name" { +} +variable "vpc_id" { +} diff --git a/examples/vpc-multi-region/README.md b/examples/vpc-multi-region/README.md new file mode 100644 index 00000000000..e45fe466619 --- /dev/null +++ b/examples/vpc-multi-region/README.md @@ -0,0 +1,18 @@ +### VPC Example + +The example will create VPC in multi region use "alias" characters. + +### Get up and running + +* Planning phase + + terraform plan + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/vpc-multi-region/main.tf b/examples/vpc-multi-region/main.tf new file mode 100644 index 00000000000..a3f946cc459 --- /dev/null +++ b/examples/vpc-multi-region/main.tf @@ -0,0 +1,21 @@ +provider "alicloud" { + alias = "bj" + region = "${var.region1}" +} + +provider "alicloud" { + alias = "hz" + region = "${var.region2}" +} + +resource "alicloud_vpc" "work" { + provider = "alicloud.hz" + name = "${var.long_name}" + cidr_block = "${var.vpc_cidr}" +} + +resource "alicloud_vpc" "control" { + provider = "alicloud.bj" + name = "${var.long_name}" + cidr_block = "${var.vpc_cidr}" +} diff --git a/examples/vpc-multi-region/outputs.tf b/examples/vpc-multi-region/outputs.tf new file mode 100644 index 00000000000..d46e24927a0 --- /dev/null +++ b/examples/vpc-multi-region/outputs.tf @@ -0,0 +1,7 @@ +output "vpc_work_id" { + value = "${alicloud_vpc.work.id}" +} + +output "vpc_control_id" { + value = "${alicloud_vpc.control.id}" +} \ No newline at end of file diff --git a/examples/vpc-multi-region/variables.tf b/examples/vpc-multi-region/variables.tf new file mode 100644 index 00000000000..c896ae47a0b --- /dev/null +++ b/examples/vpc-multi-region/variables.tf @@ -0,0 +1,12 @@ +variable "long_name" { + default = "alicloud" +} +variable "vpc_cidr" { + default = "10.1.0.0/21" +} +variable "region1" { + default = "cn-beijing" +} +variable "region2" { + default = "cn-hangzhou" +} \ No newline at end of file diff --git a/examples/vpc-route-entry/main.tf b/examples/vpc-route-entry/main.tf new file mode 100644 index 00000000000..9f6876b29b9 --- /dev/null +++ b/examples/vpc-route-entry/main.tf @@ -0,0 +1,55 @@ +resource "alicloud_vpc" "default" { + name = "tf_vpc" + cidr_block = "${var.vpc_cidr}" +} + +resource "alicloud_vswitch" "default" { + vpc_id = "${alicloud_vpc.default.id}" + cidr_block = "${var.vswitch_cidr}" + availability_zone = "${var.zone_id}" +} + +resource "alicloud_route_entry" "default" { + router_id = "${alicloud_vpc.default.router_id}" + route_table_id = "${alicloud_vpc.default.router_table_id}" + destination_cidrblock = "${var.entry_cidr}" + nexthop_type = "Instance" + nexthop_id = "${alicloud_instance.snat.id}" +} + +resource "alicloud_security_group" "sg" { + name = "tf_sg" + description = "tf_sg" + vpc_id = "${alicloud_vpc.default.id}" +} + +resource "alicloud_security_group_rule" "ssh" { + type = "ingress" + ip_protocol = "tcp" + nic_type = "intranet" + policy = "${var.rule_policy}" + port_range = "22/22" + priority = 1 + security_group_id = "${alicloud_security_group.sg.id}" + cidr_ip = "0.0.0.0/0" +} + +resource "alicloud_instance" "snat" { + # cn-beijing + availability_zone = "${var.zone_id}" + security_groups = ["${alicloud_security_group.sg.id}"] + + vswitch_id = "${alicloud_vswitch.default.id}" + allocate_public_ip = true + + # series II + instance_charge_type = "PostPaid" + instance_type = "${var.instance_type}" + internet_charge_type = "${var.internet_charge_type}" + internet_max_bandwidth_out = 5 + io_optimized = "${var.io_optimized}" + + system_disk_category = "cloud_efficiency" + image_id = "${var.image_id}" + instance_name = "tf_snat" +} \ No newline at end of file diff --git a/examples/vpc-route-entry/ouputs.tf b/examples/vpc-route-entry/ouputs.tf new file mode 100644 index 00000000000..37e60e250cb --- /dev/null +++ b/examples/vpc-route-entry/ouputs.tf @@ -0,0 +1,15 @@ +output "route_table_id" { + value = "${alicloud_route_entry.default.route_table_id}" +} + +output "router_id" { + value = "${alicloud_route_entry.default.router_id}" +} + +output "nexthop_type" { + value = "${alicloud_route_entry.default.nexthop_type}" +} + +output "nexthop_id" { + value = "${alicloud_route_entry.default.nexthop_id}" +} \ No newline at end of file diff --git a/examples/vpc-route-entry/variables.tf b/examples/vpc-route-entry/variables.tf new file mode 100644 index 00000000000..4708e266f5a --- /dev/null +++ b/examples/vpc-route-entry/variables.tf @@ -0,0 +1,28 @@ + +variable "vpc_cidr" { + default = "10.1.0.0/21" +} +variable "vswitch_cidr" { + default = "10.1.1.0/24" +} +variable "zone_id" { + default = "cn-beijing-c" +} +variable "entry_cidr" { + default = "172.11.1.1/32" +} +variable "rule_policy" { + default = "accept" +} +variable "instance_type" { + default = "ecs.n1.small" +} +variable "image_id" { + default = "ubuntu_140405_64_40G_cloudinit_20161115.vhd" +} +variable "internet_charge_type" { + default = "PayByTraffic" +} +variable "io_optimized" { + default = "optimized" +} \ No newline at end of file diff --git a/examples/vpc/README.md b/examples/vpc/README.md new file mode 100644 index 00000000000..392e0abc8d1 --- /dev/null +++ b/examples/vpc/README.md @@ -0,0 +1,18 @@ +### VPC Example + +The example create VPC, VSwitch, Natgateway. The variables.tf can let you create specify parameter instances, such as availability_zone, cidr_block etc. + +### Get up and running + +* Planning phase + + terraform plan + +* Apply phase + + terraform apply + + +* Destroy + + terraform destroy \ No newline at end of file diff --git a/examples/vpc/main.tf b/examples/vpc/main.tf new file mode 100644 index 00000000000..78d58b17cc9 --- /dev/null +++ b/examples/vpc/main.tf @@ -0,0 +1,28 @@ +resource "alicloud_vpc" "main" { + name = "${var.long_name}" + cidr_block = "${var.vpc_cidr}" +} + +resource "alicloud_vswitch" "main" { + vpc_id = "${alicloud_vpc.main.id}" + count = "${length(split(",", var.availability_zones))}" + cidr_block = "${lookup(var.cidr_blocks, "az${count.index}")}" + availability_zone = "${var.availability_zones}" + depends_on = [ + "alicloud_vpc.main"] +} + +resource "alicloud_nat_gateway" "main" { + vpc_id = "${alicloud_vpc.main.id}" + spec = "Small" + bandwidth_packages = [ + { + ip_count = 1 + bandwidth = 5 + zone = "${var.availability_zones}" + } + ] + depends_on = [ + "alicloud_vswitch.main"] +} + diff --git a/examples/vpc/outputs.tf b/examples/vpc/outputs.tf new file mode 100644 index 00000000000..06809a16a88 --- /dev/null +++ b/examples/vpc/outputs.tf @@ -0,0 +1,11 @@ +output "vpc_id" { + value = "${alicloud_vpc.main.id}" +} + +output "vswitch_ids" { + value = "${join(",", alicloud_vswitch.main.*.id)}" +} + +output "availability_zones" { + value = "${join(",",alicloud_vswitch.main.*.availability_zone)}" +} diff --git a/examples/vpc/variables.tf b/examples/vpc/variables.tf new file mode 100644 index 00000000000..2b30cde0571 --- /dev/null +++ b/examples/vpc/variables.tf @@ -0,0 +1,25 @@ +variable "availability_zones" { + default = "cn-beijing-c" +} + +variable "cidr_blocks" { + type = "map" + default = { + az0 = "10.1.1.0/24" + az1 = "10.1.2.0/24" + az2 = "10.1.3.0/24" + } +} + +variable "long_name" { + default = "alicloud" +} +variable "short_name" { + default = "ali" +} +variable "vpc_cidr" { + default = "10.1.0.0/21" +} +variable "region" { + default = "cn-beijing" +} \ No newline at end of file