创建多台ECS实例
本文介绍如何使用Terraform模块批量创建多台ECS实例。
操作步骤
操作样例
provider "alicloud" {}
resource "alicloud_vpc" "vpc" {
name = "tf_test_foo"
cidr_block = "172.16.0.0/12"
}
resource "alicloud_vswitch" "vsw" {
vpc_id = "${alicloud_vpc.vpc.id}"
cidr_block = "172.16.0.0/21"
availability_zone = "cn-beijing-b"
}
resource "alicloud_security_group" "default" {
name = "default"
vpc_id = "${alicloud_vpc.vpc.id}"
}
resource "alicloud_security_group_rule" "allow_all_tcp" {
type = "ingress"
ip_protocol = "tcp"
nic_type = "intranet"
policy = "accept"
port_range = "1/65535"
priority = 1
security_group_id = "${alicloud_security_group.default.id}"
cidr_ip = "0.0.0.0/0"
}
module "tf-instances" {
source = "alibaba/ecs-instance/alicloud"
vswitch_id = "${alicloud_vswitch.vsw.id}"
group_ids = ["${alicloud_security_group.default.*.id}"]
availability_zone = "cn-beijing-b"
disk_category = "cloud_ssd"
disk_name = "my_module_disk"
disk_size = "50"
number_of_disks = 7
instance_name = "my_module_instances_"
host_name = "sample"
internet_charge_type = "PayByTraffic"
number_of_instances = "3"
password="User@123"
}
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
评论