@@ -21,7 +21,7 @@ resource "alicloud_vpc" "new" {
21
21
// According to the vswitch cidr blocks to launch several vswitches
22
22
resource "alicloud_vswitch" "new" {
23
23
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 ]
25
25
cidr_block = var. vswitch_cidrs [count . index ]
26
26
availability_zone = length (var. availability_zones ) > 0 ? element (var. availability_zones , count. index ) : element (data. alicloud_zones . default . ids . * , count. index )
27
27
name = local. new_vpc_name
@@ -30,7 +30,7 @@ resource "alicloud_vswitch" "new" {
30
30
31
31
resource "alicloud_nat_gateway" "new" {
32
32
count = var. new_vpc == true ? 1 : 0
33
- vpc_id = alicloud_vpc. new . 0 . id
33
+ vpc_id = concat ( alicloud_vpc. new . * . id , [ " " ])[ 0 ]
34
34
name = local. new_vpc_name
35
35
// tags = local.new_vpc_tags
36
36
}
@@ -44,13 +44,13 @@ resource "alicloud_eip" "new" {
44
44
45
45
resource "alicloud_eip_association" "new" {
46
46
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 ]
49
49
}
50
50
51
51
resource "alicloud_snat_entry" "new" {
52
52
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 ]
54
54
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 ]
56
56
}
0 commit comments