使用terraform 创建实例模板如下:
data "tencentcloud_images" "my_favorite_image" {
image_type = ["PUBLIC_IMAGE"]
os_name = "Tencent Linux release 3.2 (Final)"
}
data "tencentcloud_instance_types" "my_favorite_instance_types" {
filter {
name = "instance-family"
values = ["S3"]
}
cpu_core_count = 1
memory_size = 1
}
data "tencentcloud_availability_zones" "my_favorite_zones" {
}
// Create VPC resource
resource "tencentcloud_vpc" "app" {
cidr_block = "10.0.0.0/16"
name = "awesome_app_vpc"
}
resource "tencentcloud_subnet" "app" {
vpc_id = tencentcloud_vpc.app.id
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
name = "awesome_app_subnet"
cidr_block = "10.0.1.0/24"
}
// Create 2 CVM instances to host awesome_app
resource "tencentcloud_instance" "my_awesome_app" {
instance_name = "awesome_app"
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
system_disk_type = "CLOUD_PREMIUM"
system_disk_size = 50
hostname = "user"
project_id = 0
vpc_id = tencentcloud_vpc.app.id
subnet_id = tencentcloud_subnet.app.id
count = 2
data_disks {
data_disk_type = "CLOUD_PREMIUM"
data_disk_size = 50
encrypt = false
}
tags = {
tagKey = "tagValue"
}
}
问题在于使用data_disks块,无法在这个块中使用for_each或count来创建多个数据盘。
如若使用resource来创建cbs作为数据盘的话,这样确实可以使用count或for_each来创建数据盘,但无法做到为每个实例都创建多个数据盘,这样的操作需要双循环。而terraform似乎无法实现?
相似问题