To add a secondary IP range to a subnetwork after it has been created using Terraform on GCP, the following steps will be necessary:
Identify the existing subnetwork resource in your Terraform configuration file.
resource "google_compute_subnetwork" "example" {
name = "example-subnet"
ip_cidr_range = "10.0.1.0/24"
network = google_compute_network.example.self_link
region = "us-central1"
private_ip_google_access = true
}
Add a secondaryiprange block inside the subnetwork resource.
resource "google_compute_subnetwork" "example" {
name = "example-subnet"
ip_cidr_range = "10.0.1.0/24"
network = google_compute_network.example.self_link
region = "us-central1"
private_ip_google_access = true
secondary_ip_range {
range_name = "example-range"
ip_cidr_range = "10.0.2.0/24"
}
}
Save the changes to the Terraform configuration file.
Run the terraform apply
command to apply the changes to the GCP environment.
$ terraform apply
After these steps are completed, the secondary IP range will be added to the existing subnetwork.
Asked: 2022-06-17 11:00:00 +0000
Seen: 10 times
Last updated: May 21 '21