@@ -21,7 +21,7 @@ resource "alicloud_vpc" "new" {
2121// According to the vswitch cidr blocks to launch several vswitches
2222resource "alicloud_vswitch" "new" {
2323 count = var. new_vpc == true ? length (var. vswitch_cidrs ) : 0
24- vpc_id = alicloud_vpc. new . 0 . id
24+ vpc_id = concat ( alicloud_vpc. new . * . id , [ " " ])[ 0 ]
2525 cidr_block = var. vswitch_cidrs [count . index ]
2626 availability_zone = length (var. availability_zones ) > 0 ? element (var. availability_zones , count. index ) : element (data. alicloud_zones . default . ids . * , count. index )
2727 name = local. new_vpc_name
@@ -30,7 +30,7 @@ resource "alicloud_vswitch" "new" {
3030
3131resource "alicloud_nat_gateway" "new" {
3232 count = var. new_vpc == true ? 1 : 0
33- vpc_id = alicloud_vpc. new . 0 . id
33+ vpc_id = concat ( alicloud_vpc. new . * . id , [ " " ])[ 0 ]
3434 name = local. new_vpc_name
3535 // tags = local.new_vpc_tags
3636}
@@ -44,13 +44,13 @@ resource "alicloud_eip" "new" {
4444
4545resource "alicloud_eip_association" "new" {
4646 count = var. new_vpc == true ? 1 : 0
47- allocation_id = alicloud_eip. new . 0 . id
48- instance_id = alicloud_nat_gateway. new . 0 . id
47+ allocation_id = concat ( alicloud_eip. new . * . id , [ " " ])[ 0 ]
48+ instance_id = concat ( alicloud_nat_gateway. new . * . id , [ " " ])[ 0 ]
4949}
5050
5151resource "alicloud_snat_entry" "new" {
5252 count = var. new_vpc == true ? length (var. vswitch_cidrs ) : 0
53- snat_table_id = alicloud_nat_gateway. new . 0 . snat_table_ids
53+ snat_table_id = concat ( alicloud_nat_gateway. new . * . snat_table_ids , [ " " ])[ 0 ]
5454 source_vswitch_id = alicloud_vswitch. new [count . index ]. id
55- snat_ip = alicloud_eip. new . 0 . ip_address
55+ snat_ip = concat ( alicloud_eip. new . * . ip_address , [ " " ])[ 0 ]
5656}
0 commit comments