Skip to content

Commit 9d8d491

Browse files
committed
added subnetwork variable, terraform fmt
1 parent ca67d66 commit 9d8d491

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Diff for: main.tf

+6
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ data "google_compute_network" "network" {
2121
project = "${var.network_project == "" ? var.project : var.network_project}"
2222
}
2323

24+
data "google_compute_subnetwork" "network" {
25+
name = "${var.subnetwork}"
26+
project = "${var.network_project == "" ? var.project : var.network_project}"
27+
}
28+
2429
resource "google_compute_forwarding_rule" "default" {
2530
project = "${var.project}"
2631
name = "${var.name}"
2732
region = "${var.region}"
2833
network = "${data.google_compute_network.network.self_link}"
34+
subnetwork = "${data.google_compute_subnetwork.network.self_link}"
2935
load_balancing_scheme = "INTERNAL"
3036
backend_service = "${google_compute_region_backend_service.default.self_link}"
3137
ip_address = "${var.ip_address}"

Diff for: outputs.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
16+
1717
output ip_address {
1818
description = "The internal IP assigned to the regional fowarding rule."
1919
value = "${google_compute_forwarding_rule.default.ip_address}"

Diff for: variables.tf

+8-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
16+
1717
variable project {
1818
description = "The project to deploy to, if not set the default provider project is used."
1919
default = ""
@@ -29,9 +29,14 @@ variable network {
2929
default = "default"
3030
}
3131

32+
variable subnetwork {
33+
description = "Name of the subnetwork to create resources in."
34+
default = "default"
35+
}
36+
3237
variable network_project {
3338
description = "Name of the project for the network. Useful for shared VPC. Default is var.project."
34-
default = ""
39+
default = ""
3540
}
3641

3742
variable name {
@@ -74,5 +79,5 @@ variable ip_address {
7479

7580
variable ip_protocol {
7681
description = "The IP protocol for the backend and frontend forwarding rule. TCP or UDP."
77-
default = "TCP"
82+
default = "TCP"
7883
}

0 commit comments

Comments
 (0)