From 80e060ba8fceda4400901dec56f326dabbe0f0a1 Mon Sep 17 00:00:00 2001 From: Ludo Date: Tue, 16 Apr 2024 08:51:32 +0200 Subject: [PATCH 1/3] remove data source from net-vpc module --- modules/net-vpc/main.tf | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/net-vpc/main.tf b/modules/net-vpc/main.tf index 7c7ee56412..101cf1bbbe 100644 --- a/modules/net-vpc/main.tf +++ b/modules/net-vpc/main.tf @@ -17,8 +17,24 @@ locals { network = ( var.vpc_create - ? try(google_compute_network.network.0, null) - : try(data.google_compute_network.network.0, null) + ? { + id = try(google_compute_network.network.0.id, null) + name = try(google_compute_network.network.0.name, null) + self_link = try(google_compute_network.network.0.self_link, null) + } + : { + id = format( + "projects/%s/global/networks/%s", + var.project_id, + var.name + ) + name = var.name + self_link = format( + "https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s", + var.project_id, + var.name + ) + } ) peer_network = ( var.peering_config == null From d441144d90dffd90d6bb720a3b5ee3ad30ba1516 Mon Sep 17 00:00:00 2001 From: Ludo Date: Tue, 16 Apr 2024 09:07:33 +0200 Subject: [PATCH 2/3] fix test inventories --- tests/modules/net_vpc/psa_routes_export.yaml | 2 -- tests/modules/net_vpc/psa_routes_import.yaml | 2 -- tests/modules/net_vpc/psa_routes_import_export.yaml | 3 --- 3 files changed, 7 deletions(-) diff --git a/tests/modules/net_vpc/psa_routes_export.yaml b/tests/modules/net_vpc/psa_routes_export.yaml index a2ca40ea2c..6b42919bb7 100644 --- a/tests/modules/net_vpc/psa_routes_export.yaml +++ b/tests/modules/net_vpc/psa_routes_export.yaml @@ -46,10 +46,8 @@ counts: google_service_networking_connection: 1 outputs: - name: __missing__ network: __missing__ project_id: test-project - self_link: __missing__ subnet_ips: {} subnet_regions: {} subnet_secondary_ranges: {} diff --git a/tests/modules/net_vpc/psa_routes_import.yaml b/tests/modules/net_vpc/psa_routes_import.yaml index 5d7708ae2c..1bf772884c 100644 --- a/tests/modules/net_vpc/psa_routes_import.yaml +++ b/tests/modules/net_vpc/psa_routes_import.yaml @@ -46,10 +46,8 @@ counts: google_service_networking_connection: 1 outputs: - name: __missing__ network: __missing__ project_id: test-project - self_link: __missing__ subnet_ips: {} subnet_regions: {} subnet_secondary_ranges: {} diff --git a/tests/modules/net_vpc/psa_routes_import_export.yaml b/tests/modules/net_vpc/psa_routes_import_export.yaml index 42b8460d16..d74c51c345 100644 --- a/tests/modules/net_vpc/psa_routes_import_export.yaml +++ b/tests/modules/net_vpc/psa_routes_import_export.yaml @@ -46,10 +46,7 @@ counts: google_service_networking_connection: 1 outputs: - name: __missing__ - network: __missing__ project_id: test-project - self_link: __missing__ subnet_ips: {} subnet_regions: {} subnet_secondary_ranges: {} From b1c4f07a6593db3ca316482ffeb296474463220e Mon Sep 17 00:00:00 2001 From: Ludo Date: Tue, 16 Apr 2024 09:21:47 +0200 Subject: [PATCH 3/3] remove data source, fix fast inventories --- modules/net-vpc/main.tf | 6 ------ tests/fast/stages/s2_networking_a_peering/stage.yaml | 2 +- tests/fast/stages/s2_networking_b_vpn/stage.yaml | 2 +- tests/fast/stages/s2_networking_c_nva/stage.yaml | 4 ++-- tests/fast/stages/s2_networking_d_separate_envs/stage.yaml | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/net-vpc/main.tf b/modules/net-vpc/main.tf index 101cf1bbbe..6ace07a53e 100644 --- a/modules/net-vpc/main.tf +++ b/modules/net-vpc/main.tf @@ -43,12 +43,6 @@ locals { ) } -data "google_compute_network" "network" { - count = var.vpc_create ? 0 : 1 - project = var.project_id - name = var.name -} - resource "google_compute_network" "network" { count = var.vpc_create ? 1 : 0 project = var.project_id diff --git a/tests/fast/stages/s2_networking_a_peering/stage.yaml b/tests/fast/stages/s2_networking_a_peering/stage.yaml index 8d72580764..3ee8b9901e 100644 --- a/tests/fast/stages/s2_networking_a_peering/stage.yaml +++ b/tests/fast/stages/s2_networking_a_peering/stage.yaml @@ -14,4 +14,4 @@ counts: modules: 29 - resources: 153 + resources: 151 diff --git a/tests/fast/stages/s2_networking_b_vpn/stage.yaml b/tests/fast/stages/s2_networking_b_vpn/stage.yaml index 79a0e4167a..af6e5cac7b 100644 --- a/tests/fast/stages/s2_networking_b_vpn/stage.yaml +++ b/tests/fast/stages/s2_networking_b_vpn/stage.yaml @@ -14,4 +14,4 @@ counts: modules: 31 - resources: 190 + resources: 188 diff --git a/tests/fast/stages/s2_networking_c_nva/stage.yaml b/tests/fast/stages/s2_networking_c_nva/stage.yaml index b4e8299d08..db5d39c5dc 100644 --- a/tests/fast/stages/s2_networking_c_nva/stage.yaml +++ b/tests/fast/stages/s2_networking_c_nva/stage.yaml @@ -22,7 +22,7 @@ counts: google_compute_ha_vpn_gateway: 2 google_compute_health_check: 8 google_compute_instance_template: 4 - google_compute_network: 6 + google_compute_network: 4 google_compute_network_peering: 4 google_compute_region_backend_service: 4 google_compute_region_instance_group_manager: 4 @@ -53,4 +53,4 @@ counts: google_vpc_access_connector: 2 modules: 43 random_id: 2 - resources: 203 + resources: 201 diff --git a/tests/fast/stages/s2_networking_d_separate_envs/stage.yaml b/tests/fast/stages/s2_networking_d_separate_envs/stage.yaml index 6df5c894d3..1c560f7678 100644 --- a/tests/fast/stages/s2_networking_d_separate_envs/stage.yaml +++ b/tests/fast/stages/s2_networking_d_separate_envs/stage.yaml @@ -14,4 +14,4 @@ counts: modules: 22 - resources: 174 + resources: 172