Open kavya498 opened 2 years ago
https://github.com/terraform-alicloud-modules/terraform-alicloud-vpc/blob/master/main.tf#L22
resource "alicloud_vpc" "vpc" { count = var.vpc_id != "" ? 0 : var.create ? 1 : 0 vpc_name = var.vpc_name cidr_block = var.vpc_cidr resource_group_id = var.resource_group_id description = var.vpc_description tags = merge( { "Name" = format("%s", var.vpc_name) }, var.vpc_tags, ) } resource "alicloud_vswitch" "vswitches" { count = local.create_sub_resources ? length(var.vswitch_cidrs) : 0 vpc_id = var.vpc_id != "" ? var.vpc_id : concat(alicloud_vpc.vpc.*.id, [""])[0] cidr_block = var.vswitch_cidrs[count.index] availability_zone = element(var.availability_zones, count.index) vswitch_name = length(var.vswitch_cidrs) > 1 || var.use_num_suffix ? format("%s%03d", var.vswitch_name, count.index + 1) : var.vswitch_name description = var.vswitch_description tags = merge( { Name = format( "%s%03d", var.vswitch_name, count.index + 1 ) }, var.vswitch_tags, ) }
https://github.com/terraform-alicloud-modules/terraform-alicloud-vpc/blob/master/main.tf#L22