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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-06-17 11:00:00 +0000
Seen: 10 times
Last updated: May 21 '21
How can two GCP instances with static IPs be created using Terraform?
What is the process for uploading files to Azure Storage using Terraform in Azure Pipeline?
How can ec2 instances be created in every availability zone using Terraform?
How to use Terraform to make an S3 Bucket accessible to the public?