How to create subnets in GCP cloud using Terraform

0 votes

Hi Guys,

I have created a network in the GCP cloud. Now I want to create a subnet in this network using Terraform. How can I do that?

Sep 13, 2020 in Terraform by akhtar
• 38,170 points
367 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to create a network first. A subnet is always a part of a network. So before subnet, you have to create one network as shown below.

resource "google_compute_subnetwork" "network-for-l7lb" {
  provider = google-beta
  name          = "l7lb-test-subnetwork"
  ip_cidr_range = "10.0.0.0/24"
  region        = "us-central1"
  purpose       = "INTERNAL_HTTPS_LOAD_BALANCER"
  role          = "ACTIVE"
  network       = google_compute_network.custom-test.id
}
resource "google_compute_network" "custom-test" {
  provider = google-beta
  name                    = "l7lb-test-network"
  auto_create_subnetworks = false
}
answered Sep 13, 2020 by MD
• 95,160 points

Related Questions In Terraform

0 votes
2 answers

How to create a customized IAM policy in GCP using Terraform?

You can visit Terraform official site for ...READ MORE

answered Sep 13, 2020 in Terraform by Peter
• 180 points
378 views
0 votes
1 answer

How to create a security rule in GCP using Terraform?

Hi@akhtar, A Security Policy defines an IP blacklist ...READ MORE

answered Sep 13, 2020 in Terraform by MD
• 95,160 points
139 views
0 votes
1 answer

How to create Filestore instance in GCP using Terraform?

Hi@akhtar, You can manage services in the GCP ...READ MORE

answered Sep 13, 2020 in Terraform by MD
• 95,160 points
204 views
0 votes
1 answer

How to create one key in AWS using terraform?

Hi@akhtar, You can use aws_key_pair resource n terraform. ...READ MORE

answered Jun 11, 2020 in Terraform by MD
• 95,160 points
664 views
0 votes
1 answer

How to create a service account in GCP using Terraform?

Hi@akhtar, You can create a service account in ...READ MORE

answered Sep 12, 2020 in Terraform by MD
• 95,160 points
402 views
0 votes
1 answer

How to launch an instance in GCP using Terraform?

Hi@akhtar, You can use the google_compute_instance resource in ...READ MORE

answered Sep 12, 2020 in Terraform by MD
• 95,160 points
140 views
0 votes
1 answer

Create a project in GCP using Terraform.

Hi@akhtar, Terraform has a resource named google_project. This ...READ MORE

answered Sep 13, 2020 in Terraform by MD
• 95,160 points
193 views
0 votes
1 answer

How to set an IAM policy for a project in GCP using Terraform?

Hi@akhtar, You can create a policy and give ...READ MORE

answered Sep 13, 2020 in Terraform by akhtar
• 38,170 points
204 views
0 votes
1 answer

How to create a service account key in GCP Cloud using Terraform?

Hi@akhtar, You need to create a service account ...READ MORE

answered Sep 12, 2020 in Terraform by MD
• 95,160 points
378 views
0 votes
1 answer

How to create a VPC in GCP Cloud using Terraform code?

Hi@akhtar, You can create your own VPC in ...READ MORE

answered Sep 13, 2020 in Terraform by MD
• 95,160 points
418 views