Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove data source from net-vpc module #2216

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions modules/net-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,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
Expand Down
2 changes: 1 addition & 1 deletion tests/fast/stages/s2_networking_a_peering/stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

counts:
modules: 29
resources: 153
resources: 151
2 changes: 1 addition & 1 deletion tests/fast/stages/s2_networking_b_vpn/stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

counts:
modules: 31
resources: 190
resources: 188
4 changes: 2 additions & 2 deletions tests/fast/stages/s2_networking_c_nva/stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,4 +53,4 @@ counts:
google_vpc_access_connector: 2
modules: 43
random_id: 2
resources: 203
resources: 201
2 changes: 1 addition & 1 deletion tests/fast/stages/s2_networking_d_separate_envs/stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

counts:
modules: 22
resources: 174
resources: 172
2 changes: 0 additions & 2 deletions tests/modules/net_vpc/psa_routes_export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
2 changes: 0 additions & 2 deletions tests/modules/net_vpc/psa_routes_import.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
3 changes: 0 additions & 3 deletions tests/modules/net_vpc/psa_routes_import_export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
Loading