Switch to using an explicit net/subnet.

This commit is contained in:
Tom Alexander
2021-07-13 01:30:22 -04:00
parent 9d8a1f2142
commit b92396d321
3 changed files with 59 additions and 9 deletions

View File

@@ -3,11 +3,21 @@ variable "project" {
type = string
}
variable "region" {
description = "Region."
type = string
}
output "private_network_id" {
description = "Private network id."
value = google_compute_network.private_network.id
}
output "private_subnetwork_id" {
description = "Private subnetwork id."
value = google_compute_subnetwork.subnet.id
}
resource "google_project_service" "servicenetworking" {
project = var.project
service = "servicenetworking.googleapis.com"
@@ -23,6 +33,13 @@ resource "google_compute_network" "private_network" {
]
}
resource "google_compute_subnetwork" "subnet" {
name = "private-subnetwork"
ip_cidr_range = "10.100.0.0/16"
region = var.region
network = google_compute_network.private_network.id
}
resource "google_compute_global_address" "private_ip_address" {
project = google_compute_network.private_network.project
name = "private-ip-address"