Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit ee46c8f

Browse files
authored
feat: create default VPC network if it does not exist already (#1052)
* feat: create `default` network if it does not exist already * fix: comments must end with a period
1 parent e102aef commit ee46c8f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

provisioning/terraform/network.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Define a data source to fetch the `default` VPC network.
16+
data "google_compute_network" "default" {
17+
name = "default"
18+
}
19+
20+
# Create the `default` VPC network if it does not exist.
21+
resource "google_compute_network" "default" {
22+
name = "default"
23+
24+
# Only create the network if it does not exist.
25+
count = data.google_compute_network.default.name == "" ? 1 : 0
26+
}

0 commit comments

Comments
 (0)