{"id":2831,"date":"2023-08-01T06:49:40","date_gmt":"2023-08-01T05:49:40","guid":{"rendered":"https:\/\/www.easydeploy.io\/blog\/?p=2831"},"modified":"2023-08-01T06:49:40","modified_gmt":"2023-08-01T05:49:40","slug":"create-vpc-network-using-terraform-in-gcp","status":"publish","type":"post","link":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/","title":{"rendered":"How to create VPC Network in Google Cloud using Terraform"},"content":{"rendered":"<p><strong>GCP VPC Network<\/strong> service is provided by Google Cloud Platform (GCP) which allows you to create and manage your own logically isolated virtual network in the cloud. A VPC provides a <strong>secure and scalable<\/strong> foundation for running your applications and services in <strong>GCP<\/strong>.<\/p>\n<p>With <strong><a href=\"https:\/\/www.easydeploy.io\/google-cloud-consulting-services\" target=\"_blank\" rel=\"noopener\">Google Cloud<\/a> VPC<\/strong>, you can define and control IP addressing, subnets, routing, and firewall rules for your virtual network in google cloud. It allows you to segment your resources into <strong>different subnets<\/strong>, each residing in a specific region. This <strong>segmentation<\/strong> helps in organizing and isolating Various components of your <strong>Cloud infrastructure<\/strong>, providing <strong>improved security<\/strong> and<strong> network performance<\/strong>.<\/p>\n<p><span>Creating a <strong>GCP VPC Network<\/strong> using <strong>Terraform<\/strong> allows you to automate the provisioning and configuration of your network infrastructure. <a href=\"https:\/\/www.easydeploy.io\/blog\/what-is-terramform\/\" target=\"_blank\" rel=\"noopener\"><strong>Terraform<\/strong><\/a> is an infrastructure as code (IaC) tool that uses declarative configuration files to define and manage your infrastructure. By leveraging Terraform, you can easily create and manage a <strong>GCP VPC Network<\/strong> with its associated <strong>subnets, firewall rules, routes<\/strong>, and<strong> other networking<\/strong> components. This provides a repeatable and consistent way to create and maintain your <strong>network infrastructure<\/strong>, reducing manual effort and ensuring infrastructure consistency across <strong>different environments<\/strong>.<\/span><\/p>\n<p>In this blog, we will create a <strong>VPC Network<\/strong> with <strong>Public<\/strong> and<strong> Private subnets<\/strong> and a Cloud Nat with Route using <strong>Terraform script<\/strong>. Let&#8217;s dive into the <strong>demo<\/strong>.<\/p>\n<h2>Prerequisites to Create GCP VPC Network<\/h2>\n<p>Before diving in please make sure that your machine you have to <strong>install<\/strong> the following tools.<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.hashicorp.com\/terraform\/tutorials\/aws-get-started\/install-cli\">Terraform CLI<\/a><\/li>\n<li><a href=\"https:\/\/cloud.google.com\/sdk\/docs\/install\">Gcloud CLI<\/a><\/li>\n<li><a href=\"https:\/\/code.visualstudio.com\/download\">VS Code<\/a><\/li>\n<\/ul>\n<h2>Configuring GCP CLI<\/h2>\n<p>Open <strong>VS Code editor<\/strong> with the folder where you will <strong>write<\/strong> your <strong>terraform script<\/strong>.\u00a0 Then, select the terminal at the top of the VS code and click the <strong>New Terminal button<\/strong>. It will open a command line terminal.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-2.png\" alt=\"New Terminal button\" width=\"643\" height=\"408\" class=\"aligncenter wp-image-2836 size-full\" title=\"VS Code Terminal\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-2.png 643w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/1-2-300x190.png 300w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><\/p>\n<p>Run the following command in the terminal to <strong>authenticate<\/strong> with your <strong>Google Cloud account<\/strong>.<\/p>\n<pre>gcloud auth login<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2-1-e1688721763986-1024x146.png\" alt=\"GCP authentication login\" width=\"1024\" height=\"146\" class=\"aligncenter wp-image-2837 size-large\" title=\"gcloud auth login\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2-1-e1688721763986-1024x146.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2-1-e1688721763986-300x43.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2-1-e1688721763986-768x109.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/2-1-e1688721763986.png 1048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>It will redirect you to your browser and ask you to choose the <strong>Gmail account<\/strong> that you have in your <strong>GCP account<\/strong>. If you haven&#8217;t been redirected to the browser like the below picture, Press the<strong> ctrl button<\/strong> on your Keyboard and click the <strong>link<\/strong> that would appear in your terminal like the above <strong>screenshot<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3-2.png\" alt=\"gcloud sdk\" width=\"543\" height=\"630\" class=\"aligncenter wp-image-2838 size-full\" title=\"Select Gcloud SDK\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3-2.png 543w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3-2-259x300.png 259w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/p>\n<p>It will ask for some access to your <strong>GCP account<\/strong>. Make sure you have read all the things and then click<strong> Allow<\/strong> button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3a.png\" alt=\"Gcloud SDK\" width=\"487\" height=\"904\" class=\"aligncenter wp-image-2839 size-full\" title=\"Allow Gcloud SDK\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3a.png 487w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/3a-162x300.png 162w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><\/p>\n<p>Now you will be redirected to a <strong>confirmation page<\/strong> that looks exactly like the below picture.\u00a0 You can go to your <strong>VS code editor<\/strong> terminal and that will look like the second picture.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-2.png\" alt=\"gcloud cli\" width=\"1436\" height=\"660\" class=\"aligncenter wp-image-2840 size-full\" title=\"Authenticated GCloud CLI\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-2.png 1436w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-2-300x138.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-2-1024x471.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/4-2-768x353.png 768w\" sizes=\"(max-width: 1436px) 100vw, 1436px\" \/><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/5-1.png\" alt=\"gcloud cli\" width=\"657\" height=\"375\" class=\"aligncenter wp-image-2841 size-full\" title=\"Authenticated GCloud CLI\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/5-1.png 657w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/5-1-300x171.png 300w\" sizes=\"(max-width: 657px) 100vw, 657px\" \/><\/p>\n<h2>\u00a0Writing Terraform script for Create VPC Network<\/h2>\n<p>In the VS Code editor create a new file called <strong>main.tf<\/strong> and copy the below script and paste it in the file.<\/p>\n<div>\n<div>\n<pre><span>provider<\/span><span> <\/span><span>\"google\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>project<\/span><span> <\/span><span>=<\/span><span> <\/span><span>var<\/span><span>.<\/span><span>project_id<\/span>\r\n<span>  <\/span><span>region<\/span><span> \u00a0<\/span><span>=<\/span><span> <\/span><span>var<\/span><span>.<\/span><span>region<\/span>\r\n<span>}<\/span>\r\n\r\n<span>data<\/span><span> <\/span><span>\"google_compute_zones\"<\/span><span> <\/span><span>\"this\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>region<\/span><span> \u00a0<\/span><span>=<\/span><span> <\/span><span>var<\/span><span>.<\/span><span>region<\/span>\r\n<span>  <\/span><span>project<\/span><span> <\/span><span>=<\/span><span> <\/span><span>var<\/span><span>.<\/span><span>project_id<\/span>\r\n<span>}<\/span>\r\n\r\n<span>locals<\/span><span> {<\/span>\r\n<span>  <\/span><span>type<\/span><span>   <\/span><span>=<\/span><span> <\/span><span>[<\/span><span>\"public\"<\/span><span>, <\/span><span>\"private\"<\/span><span>]<\/span>\r\n<span>  <\/span><span>zones<\/span><span> <\/span><span>=<\/span><span> <\/span><span>data<\/span><span>.<\/span><span>google_compute_zones<\/span><span>.<\/span><span>this<\/span><span>.<\/span><span>names<\/span>\r\n<span>}<\/span><\/pre>\n<\/div>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-2.png\" alt=\"Terraform script FOR VPC Network\" width=\"673\" height=\"347\" class=\"aligncenter wp-image-2842 size-full\" title=\"Terraform google provider\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-2.png 673w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/6-2-300x155.png 300w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/p>\n<p>The second resource <strong>&#8220;<\/strong><span><strong><em>google_compute_zones<\/em>&#8220;<\/strong> will help to get the list of all availability zones in the specific region.\u00a0<\/span><\/p>\n<p><span><\/span>Create another file<strong> variables.tf<\/strong> and paste the below code into that file.<\/p>\n<div>\n<div>\n<pre><span>variable<\/span><span> <\/span><span>\"project_id\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>type<\/span><span> \u00a0 \u00a0    \u00a0  <\/span><span>=<\/span><span> <\/span><span>string<\/span>\r\n<span>  <\/span><span>description <\/span><span> <\/span><span>=<\/span><span> <\/span><span>\"Project ID\"<\/span>\r\n<span>  <\/span><span>default<\/span><span> \u00a0    \u00a0 <\/span><span>=<\/span><span> <\/span><span>\"&lt;your-project-id&gt;\"<\/span>\r\n<span>}<\/span>\r\n\r\n<span>variable<\/span><span> <\/span><span>\"region\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>type<\/span><span> \u00a0 \u00a0    \u00a0  <\/span><span>=<\/span><span> <\/span><span>string<\/span>\r\n<span>  <\/span><span>description <\/span><span> <\/span><span>=<\/span><span> <\/span><span>\"Region for this infrastructure\"<\/span>\r\n<span>  <\/span><span>default<\/span><span> \u00a0    \u00a0 <\/span><span>=<\/span><span> <\/span><span>\"us-central1\"<\/span>\r\n<span>}<\/span>\r\n\r\n<span>variable<\/span><span> <\/span><span>\"name\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>type<\/span><span> \u00a0 \u00a0 \u00a0     <\/span><span>=<\/span><span> <\/span><span>string<\/span>\r\n<span>  <\/span><span>description <\/span><span> <\/span><span>=<\/span><span> <\/span><span>\"Name for this infrastructure\"<\/span>\r\n<span>  <\/span><span>default<\/span><span> \u00a0   \u00a0 <\/span><span>=<\/span><span> <\/span><span>\"&lt;any-name&gt;\"<\/span>\r\n<span>}<\/span><\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/7-2.png\" alt=\"Terraform script FOR VPC Network\" width=\"659\" height=\"440\" class=\"aligncenter wp-image-2843 size-full\" title=\"Terraform variables\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/7-2.png 659w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/7-2-300x200.png 300w\" sizes=\"(max-width: 659px) 100vw, 659px\" \/><\/p>\n<\/div>\n<p>Change the default value for the project_id with your <strong>GCP Project ID<\/strong> like the above picture. Also, you can change the region as your wish.<\/p>\n<p>Enter a name for the <strong>name variable<\/strong>.<\/p>\n<p>Now again in the <strong>main.tf file<\/strong>, add this code in that file like the following screenshot.<\/p>\n<div>\n<pre><span># VPC<\/span>\r\n<span>resource<\/span><span> <\/span><span>\"google_compute_network\"<\/span><span> <\/span><span>\"this\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>name<\/span><span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0              <\/span><span>=<\/span><span> <\/span><span>\"<\/span><span>${<\/span><span>var<\/span><span>.<\/span><span>name<\/span><span>}<\/span><span>-vpc\"<\/span>\r\n<span>  <\/span><span>delete_default_routes_on_create<\/span><span> <\/span><span>=<\/span><span> <\/span><span>false<\/span>\r\n<span>  <\/span><span>auto_create_subnetworks<\/span><span> \u00a0 \u00a0 \u00a0   \u00a0 <\/span><span>=<\/span><span> <\/span><span>false<\/span>\r\n<span>  <\/span><span>routing_mode<\/span><span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0          <\/span><span>=<\/span><span> <\/span><span>\"REGIONAL\"<\/span>\r\n<span>}<\/span><\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-1.png\" alt=\"Terraform script FOR VPC Network\" width=\"511\" height=\"508\" class=\"aligncenter wp-image-2844 size-full\" title=\"Terraform GCP VPC\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-1.png 511w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-1-300x298.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/8-1-150x150.png 150w\" sizes=\"(max-width: 511px) 100vw, 511px\" \/><\/p>\n<p>The above terraform code will able to create <strong>VPC Network<\/strong> without any subnets.<\/p>\n<p><strong>In Google Cloud VPC Network is Global, which means it will span all regions.\u00a0<\/strong><\/p>\n<p>Run <em><strong>terraform init<\/strong><\/em> command in the<strong> VS Code terminal<\/strong> to initialize the terraform configurations. It will download the latest version of the<strong> GCP terraform<\/strong> provider inside your local directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/9-2.png\" alt=\"Terraform script FOR VPC Network\" width=\"599\" height=\"420\" class=\"aligncenter wp-image-2845 size-full\" title=\"Terraform init\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/9-2.png 599w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/9-2-300x210.png 300w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/p>\n<p>Once the initialization is completed, run the following apply command to create<strong> GCP VPC Network<\/strong>. It will ask for confirmation. type <strong>yes<\/strong> to approve.<\/p>\n<pre>terraform apply<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/10-2.png\" alt=\"Terraform script FOR VPC Network\" width=\"1014\" height=\"670\" class=\"aligncenter wp-image-2846 size-full\" title=\"Terraform apply\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/10-2.png 1014w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/10-2-300x198.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/10-2-768x507.png 768w\" sizes=\"(max-width: 1014px) 100vw, 1014px\" \/><\/p>\n<div>\n<p>Now open your<strong> GCP account<\/strong> in the browser and in the left side Navigation menu scroll down to the <strong>Networking<\/strong> section, select VPC Network and click the VPC Networks button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-2.png\" alt=\"GCP VPC Network\" width=\"1199\" height=\"617\" class=\"aligncenter wp-image-2847 size-full\" title=\"GCP Console VPC Network\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-2.png 1199w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-2-300x154.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-2-1024x527.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/11-2-768x395.png 768w\" sizes=\"(max-width: 1199px) 100vw, 1199px\" \/><\/p>\n<p>You can see the<strong> GCP VPC Network<\/strong> is created in the following screenshot. Click the name of the <strong>VPC<\/strong> and you can see the details of the VPC.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-2.png\" alt=\"GCP VPC Network\" width=\"1218\" height=\"452\" class=\"aligncenter wp-image-2848 size-full\" title=\"GCP Console VPC Network\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-2.png 1218w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-2-300x111.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-2-1024x380.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/12-2-768x285.png 768w\" sizes=\"(max-width: 1218px) 100vw, 1218px\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13a.png\" alt=\"GCP VPC Network details\" width=\"1258\" height=\"750\" class=\"aligncenter wp-image-2855 size-full\" title=\"GCP VPC Network details\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13a.png 1258w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13a-300x179.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13a-1024x610.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13a-768x458.png 768w\" sizes=\"(max-width: 1258px) 100vw, 1258px\" \/><\/p>\n<h2>Create Public and Private Subnets<\/h2>\n<p>We have created our <strong>VPC Network<\/strong> without any <strong>Subnets<\/strong>. So now we will create 2 subnets for <strong>public<\/strong> and <strong>private<\/strong>. Basically, Subnets in Google Cloud are Regional, which means they will spawn in all the availability zones in a region.<\/p>\n<p>Now we are going to create Public and Private subnets in a single region.<\/p>\n<p>Copy the following code and add it to th<strong>e main.<\/strong>tf file.<\/p>\n<div>\n<pre><span># SUBNETS<\/span>\r\n<span>resource<\/span><span>\"google_compute_subnetwork\"<\/span><span>\"this\"<\/span><span> {<\/span>\r\n<span>count<\/span><span>=<\/span><span> 2<\/span>\r\n<span>name<\/span><span>=<\/span><span>\"<\/span><span>${<\/span><span>var<\/span><span>.<\/span><span>name<\/span><span>}<\/span><span>-<\/span><span>${<\/span><span>local<\/span><span>.<\/span><span>type<\/span><span>[<\/span><span>count<\/span><span>.<\/span><span>index<\/span><span>]<\/span><span>}<\/span><span>-subnetwork\"<\/span>\r\n<span>ip_cidr_range<\/span><span>=<\/span><span> var<\/span><span>.<\/span><span>ip_cidr_range<\/span><span>[<\/span><span>count<\/span><span>.<\/span><span>index<\/span><span>]<\/span>\r\n<span>region<\/span><span>=<\/span><span>var<\/span><span>.<\/span><span>region<\/span>\r\n<span>network<\/span><span>=<\/span><span>google_compute_network<\/span><span>.<\/span><span>this<\/span><span>.<\/span><span>id<\/span>\r\n<span>private_ip_google_access <\/span><span>=<\/span><span>true<\/span>\r\n<span>}<\/span><\/pre>\n<\/div>\n<p>The above code will create<strong> public and private subnets.<\/strong> For <em><strong>ip_cidr_range<\/strong>\u00a0<\/em>we need to add a variable.<\/p>\n<p>So open <strong>variables.tf file<\/strong> and add the following content into that file.<\/p>\n<div>\n<pre><span>variable<\/span><span>\"ip_cidr_range\"<\/span><span> {<\/span>\r\n<span>type<\/span><span>=<\/span><span>list<\/span><span>(<\/span><span>string<\/span><span>)<\/span>\r\n<span>description<\/span><span>=<\/span><span>\"List of The range of internal addresses that are owned by this subnetwork.\"<\/span>\r\n<span>default<\/span><span>=<\/span><span>[<\/span><span>\"10.10.10.0\/24\"<\/span><span>, <\/span><span>\"10.10.20.0\/24\"<\/span><span>]<\/span>\r\n<span>}<\/span><\/pre>\n<\/div>\n<p>I have provided a list of IP ranges for subnets. It will take these 2 IP ranges to the subnets.<\/p>\n<p>Run apply the command to create subnets. You can see that 2 subnets are going to create.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-2.png\" alt=\"Terraform script FOR VPC Network\" width=\"1175\" height=\"290\" class=\"aligncenter wp-image-2849 size-full\" title=\"Terraform apply\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-2.png 1175w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-2-300x74.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-2-1024x253.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/13-2-768x190.png 768w\" sizes=\"(max-width: 1175px) 100vw, 1175px\" \/><\/p>\n<p>Once the apply completed, Open the<strong> GCP console<\/strong> and get into the created VPC, and you will able to see the subnets.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14-1.png\" alt=\"Terraform script FOR VPC Network\" width=\"1209\" height=\"358\" class=\"aligncenter wp-image-2850 size-full\" title=\"GCP Subnets\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14-1.png 1209w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14-1-300x89.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14-1-1024x303.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/14-1-768x227.png 768w\" sizes=\"(max-width: 1209px) 100vw, 1209px\" \/><\/p>\n<\/div>\n<h2>Create Cloud Nat and Attach it with Private Subnet<\/h2>\n<p>When a <strong>Private subnet<\/strong> is associated with a <strong>Nat gateway<\/strong>, then only it would consider private. Because private servers need to communicate with the internet for <strong>patch installation<\/strong> or any other software upgrades. But they are private so they can&#8217;t able to communicate on the Internet. So the <strong>Nat gateway<\/strong> will help the private servers to communicate with the internet with the help of a <strong>Public IP<\/strong>. When you create a <strong>Cloud Nat<\/strong> in Google Cloud, it will create a Public IP along with it.<\/p>\n<p>Now we need to create a <strong>Cloud Nat<\/strong> and associate the NAt with the Private subnet.<\/p>\n<p>Open your <strong>VS Code editor<\/strong> and add the following code to the <strong>main.tf file<\/strong>. this code is able to create Cloud Nat and associate it with the private subnet.<\/p>\n<div>\n<pre><span># NAT ROUTER<\/span>\r\n<span>resource<\/span><span> <\/span><span>\"google_compute_router\"<\/span><span> <\/span><span>\"this\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>name<\/span><span> \u00a0 \u00a0<\/span><span>=<\/span><span> <\/span><span>\"<\/span><span>${<\/span><span>var<\/span><span>.<\/span><span>name<\/span><span>}<\/span><span>-<\/span><span>${<\/span><span>local<\/span><span>.<\/span><span>type<\/span><span>[<\/span><span>1<\/span><span>]<\/span><span>}<\/span><span>-router\"<\/span>\r\n<span>  <\/span><span>region<\/span><span> \u00a0<\/span><span>=<\/span><span> <\/span><span>google_compute_subnetwork<\/span><span>.<\/span><span>this<\/span><span>[<\/span><span>1<\/span><span>]<\/span><span>.<\/span><span>region<\/span>\r\n<span>  <\/span><span>network<\/span><span> <\/span><span>=<\/span><span> <\/span><span>google_compute_network<\/span><span>.<\/span><span>this<\/span><span>.<\/span><span>id<\/span>\r\n<span>}<\/span>\r\n\r\n<span>resource<\/span><span> <\/span><span>\"google_compute_router_nat\"<\/span><span> <\/span><span>\"this\"<\/span><span> {<\/span>\r\n<span>  <\/span><span>name<\/span><span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span>=<\/span><span> <\/span><span>\"<\/span><span>${<\/span><span>var<\/span><span>.<\/span><span>name<\/span><span>}<\/span><span>-<\/span><span>${<\/span><span>local<\/span><span>.<\/span><span>type<\/span><span>[<\/span><span>1<\/span><span>]<\/span><span>}<\/span><span>-router-nat\"<\/span>\r\n<span>  <\/span><span>router<\/span><span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span>=<\/span><span> <\/span><span>google_compute_router<\/span><span>.<\/span><span>this<\/span><span>.<\/span><span>name<\/span>\r\n<span>  <\/span><span>region<\/span><span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span>=<\/span><span> <\/span><span>google_compute_router<\/span><span>.<\/span><span>this<\/span><span>.<\/span><span>region<\/span>\r\n<span>  <\/span><span>nat_ip_allocate_option<\/span><span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span>=<\/span><span> <\/span><span>\"AUTO_ONLY\"<\/span>\r\n<span>\u00a0 <\/span><span>source_subnetwork_ip_ranges_to_nat<\/span><span> <\/span><span>=<\/span><span> <\/span><span>\"LIST_OF_SUBNETWORKS\"<\/span>\r\n<span>  <\/span><span>subnetwork<\/span><span> {<\/span>\r\n<span> \u00a0  <\/span><span>name<\/span><span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0           <\/span><span>=<\/span><span> <\/span><span>\"<\/span><span>${<\/span><span>var<\/span><span>.<\/span><span>name<\/span><span>}<\/span><span>-<\/span><span>${<\/span><span>local<\/span><span>.<\/span><span>type<\/span><span>[<\/span><span>1<\/span><span>]<\/span><span>}<\/span><span>-subnetwork\"<\/span>\r\n<span> \u00a0  <\/span><span>source_ip_ranges_to_nat<\/span><span> <\/span><span>=<\/span><span> [\"ALL_IP_RANGES\"]<\/span>\r\n<span>  }<\/span>\r\n<span>}<\/span><\/pre>\n<\/div>\n<div>\n<div>In the terminal, execute the terraform and apply the command to <strong>create Cloud Nat<\/strong>.<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15-1.png\" alt=\"Terraform script FOR VPC Network\" width=\"1138\" height=\"282\" class=\"aligncenter wp-image-2851 size-full\" title=\"Terraform apply\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15-1.png 1138w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15-1-300x74.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15-1-1024x254.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/15-1-768x190.png 768w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/div>\n<p>Once the creation is completed open the GCP console and search for Nat and click the Cloud Nat link.<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/16.png\" alt=\"Cloud Nat GCP\" width=\"495\" height=\"203\" class=\"aligncenter wp-image-2852 size-full\" title=\"Cloud Nat GCP\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/16.png 495w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/16-300x123.png 300w\" sizes=\"(max-width: 495px) 100vw, 495px\" \/><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/17-1.png\" alt=\"GCP Cloud Nat\" width=\"773\" height=\"240\" class=\"aligncenter wp-image-2853 size-full\" title=\"GCP Cloud Nat\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/17-1.png 773w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/17-1-300x93.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/17-1-768x238.png 768w\" sizes=\"(max-width: 773px) 100vw, 773px\" \/><\/p>\n<p>There you can see the<strong> Cloud Nat<\/strong> could be created. Click the name of the cloud Nat to see the details of that Nat.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/18-1.png\" alt=\"Terraform script FOR VPC Network\" width=\"616\" height=\"550\" class=\"aligncenter wp-image-2854 size-full\" title=\"GCP Cloud Nat details\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/18-1.png 616w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/18-1-300x268.png 300w\" sizes=\"(max-width: 616px) 100vw, 616px\" \/><\/p>\n<p>Looks like in the above image you will find the <strong>Private subnet<\/strong> associated with this Cloud Nat. We have successfully created VPC Network with Public and Private Subnets and Cloud Nat.<\/p>\n<p><em>Also Read: <a href=\"https:\/\/www.easydeploy.io\/blog\/cut-down-aws-cost-using-terraform\/\">Save big on AWS cost | Reduce AWS bill using terraform (easydeploy.io)<\/a><\/em><\/p>\n<h2>Conclusion<\/h2>\n<p><span>In this blog post, we explored the process of creating a <strong>Google Cloud VPC Network<\/strong> with both public and private subnets, along with the configuration of <strong>Cloud NAT<\/strong> using Terraform. By following the step-by-step guide, you gained hands-on experience in leveraging the power of Infrastructure as Code (IaC) to set up a robust <strong>networking architecture<\/strong> in GCP.\u00a0 We also explored the configuration of Cloud NAT, which allows private instances in the VPC to access the internet while keeping their <strong>IP addresses<\/strong> hidden. Cloud NAT provides secure and controlled outbound connectivity for private resources, ensuring efficient communication with external services.<\/span><\/p>\n<p><span>Using Terraform, we defined the necessary resources such as <strong>VPC networks<\/strong>, subnets, firewall rules, and Cloud NAT configurations in a declarative manner. This approach brings consistency, repeatability, and version control to your infrastructure deployments. By writing reusable <strong>Terraform modules<\/strong>, you can further enhance your efficiency and maintainability.<\/span><\/p>\n<p>By mastering the creation of a GCP VPC with public and private subnets, along with Cloud NAT using Terraform, you have acquired a valuable skill set for designing and managing resilient and scalable network architectures in the Google Cloud. Embrace the principles of Infrastructure as Code, continuously expand your knowledge, and stay up-to-date with the latest advancements in <strong>GCP networking<\/strong>.<\/p>\n<p>We hope this blog post has provided you with practical guidance and insights into creating a GCP VPC with public and <strong>private subnets<\/strong>, along with Cloud NAT, using Terraform. By utilizing these techniques, you can efficiently build and manage your network infrastructure, enabling secure and seamless communication within your GCP environment.<\/p>\n<p>Happy Reading! Will see you in the next blog post!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GCP VPC Network service is provided by Google Cloud Platform (GCP) which allows you to create and manage your own logically isolated virtual network in the cloud. A VPC provides a secure and scalable foundation for running your applications and services in GCP. With Google Cloud VPC, you can define and control IP addressing, subnets, [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":2927,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25,424],"tags":[453],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create VPC Network using Terraform in Google Cloud<\/title>\n<meta name=\"description\" content=\"Learn how to quickly setup VPC Networks and subnets in google cloud using Terraform. Start Building your Virtualised network on Google Cloud!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create VPC Network using Terraform in Google Cloud\" \/>\n<meta property=\"og:description\" content=\"Learn how to quickly setup VPC Networks and subnets in google cloud using Terraform. Start Building your Virtualised network on Google Cloud!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/\" \/>\n<meta property=\"og:site_name\" content=\"easydeploy.io\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/Jerinrathnam\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-01T05:49:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1760\" \/>\n\t<meta property=\"og:image:height\" content=\"990\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Jerin Rathnam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@jerin_rathnam\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jerin Rathnam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/\"},\"author\":{\"name\":\"Jerin Rathnam\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f\"},\"headline\":\"How to create VPC Network in Google Cloud using Terraform\",\"datePublished\":\"2023-08-01T05:49:40+00:00\",\"dateModified\":\"2023-08-01T05:49:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/\"},\"wordCount\":1340,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp\",\"keywords\":[\"VPC Network\"],\"articleSection\":[\"Google Cloud Platform\",\"Terraform\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/\",\"name\":\"How to Create VPC Network using Terraform in Google Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp\",\"datePublished\":\"2023-08-01T05:49:40+00:00\",\"dateModified\":\"2023-08-01T05:49:40+00:00\",\"description\":\"Learn how to quickly setup VPC Networks and subnets in google cloud using Terraform. Start Building your Virtualised network on Google Cloud!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp\",\"contentUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp\",\"width\":1760,\"height\":990,\"caption\":\"VPC-Network\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.easydeploy.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create VPC Network in Google Cloud using Terraform\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#website\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/\",\"name\":\"easydeploy.io\",\"description\":\"A Cloud Architect Company\",\"publisher\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.easydeploy.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\",\"name\":\"EasyDeploy Technologies Pvt Ltd\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png\",\"contentUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png\",\"width\":536,\"height\":100,\"caption\":\"EasyDeploy Technologies Pvt Ltd\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f\",\"name\":\"Jerin Rathnam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g\",\"caption\":\"Jerin Rathnam\"},\"description\":\"Jerin Rathnam is a proficient DevOps engineer who is dedicated to streamlining software development and deployment processes. He has extensive knowledge of cloud infrastructure, containerization, and CI\/CD pipelines, which enables him to effectively connect development and operations. Jerin specializes in creating numerous Terraform modules for multi-cloud infrastructure and possesses immense expertise in configuring and managing cloud infrastructure. His profound understanding of containerization, along with his experience in orchestration tools like Docker and Kubernetes, further supports his skills as a valuable DevOps engineer.\",\"sameAs\":[\"https:\/\/www.gemjerin.site\",\"https:\/\/www.facebook.com\/Jerinrathnam\",\"https:\/\/www.instagram.com\/gem_jerin_rathnam\/\",\"https:\/\/www.linkedin.com\/in\/jerin-rathnam\/\",\"https:\/\/x.com\/jerin_rathnam\",\"@jerinrathnam\"],\"url\":\"https:\/\/www.easydeploy.io\/blog\/author\/jerin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create VPC Network using Terraform in Google Cloud","description":"Learn how to quickly setup VPC Networks and subnets in google cloud using Terraform. Start Building your Virtualised network on Google Cloud!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/","og_locale":"en_GB","og_type":"article","og_title":"How to Create VPC Network using Terraform in Google Cloud","og_description":"Learn how to quickly setup VPC Networks and subnets in google cloud using Terraform. Start Building your Virtualised network on Google Cloud!","og_url":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/","og_site_name":"easydeploy.io","article_author":"https:\/\/www.facebook.com\/Jerinrathnam","article_published_time":"2023-08-01T05:49:40+00:00","og_image":[{"width":1760,"height":990,"url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp","type":"image\/webp"}],"author":"Jerin Rathnam","twitter_card":"summary_large_image","twitter_creator":"@jerin_rathnam","twitter_misc":{"Written by":"Jerin Rathnam","Estimated reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#article","isPartOf":{"@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/"},"author":{"name":"Jerin Rathnam","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f"},"headline":"How to create VPC Network in Google Cloud using Terraform","datePublished":"2023-08-01T05:49:40+00:00","dateModified":"2023-08-01T05:49:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/"},"wordCount":1340,"commentCount":0,"publisher":{"@id":"https:\/\/www.easydeploy.io\/blog\/#organization"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp","keywords":["VPC Network"],"articleSection":["Google Cloud Platform","Terraform"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/","url":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/","name":"How to Create VPC Network using Terraform in Google Cloud","isPartOf":{"@id":"https:\/\/www.easydeploy.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp","datePublished":"2023-08-01T05:49:40+00:00","dateModified":"2023-08-01T05:49:40+00:00","description":"Learn how to quickly setup VPC Networks and subnets in google cloud using Terraform. Start Building your Virtualised network on Google Cloud!","breadcrumb":{"@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#primaryimage","url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp","contentUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2023\/07\/create-VPC-Network-in-Google-Cloud-using-Terraform-.webp","width":1760,"height":990,"caption":"VPC-Network"},{"@type":"BreadcrumbList","@id":"https:\/\/www.easydeploy.io\/blog\/create-vpc-network-using-terraform-in-gcp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.easydeploy.io\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create VPC Network in Google Cloud using Terraform"}]},{"@type":"WebSite","@id":"https:\/\/www.easydeploy.io\/blog\/#website","url":"https:\/\/www.easydeploy.io\/blog\/","name":"easydeploy.io","description":"A Cloud Architect Company","publisher":{"@id":"https:\/\/www.easydeploy.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.easydeploy.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.easydeploy.io\/blog\/#organization","name":"EasyDeploy Technologies Pvt Ltd","url":"https:\/\/www.easydeploy.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png","contentUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png","width":536,"height":100,"caption":"EasyDeploy Technologies Pvt Ltd"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/939543ac3b33fadea8b5115ab9a1280f","name":"Jerin Rathnam","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ca2c2ab4a28d380073334816b42aaa40?s=96&d=mm&r=g","caption":"Jerin Rathnam"},"description":"Jerin Rathnam is a proficient DevOps engineer who is dedicated to streamlining software development and deployment processes. He has extensive knowledge of cloud infrastructure, containerization, and CI\/CD pipelines, which enables him to effectively connect development and operations. Jerin specializes in creating numerous Terraform modules for multi-cloud infrastructure and possesses immense expertise in configuring and managing cloud infrastructure. His profound understanding of containerization, along with his experience in orchestration tools like Docker and Kubernetes, further supports his skills as a valuable DevOps engineer.","sameAs":["https:\/\/www.gemjerin.site","https:\/\/www.facebook.com\/Jerinrathnam","https:\/\/www.instagram.com\/gem_jerin_rathnam\/","https:\/\/www.linkedin.com\/in\/jerin-rathnam\/","https:\/\/x.com\/jerin_rathnam","@jerinrathnam"],"url":"https:\/\/www.easydeploy.io\/blog\/author\/jerin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/2831"}],"collection":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/comments?post=2831"}],"version-history":[{"count":11,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/2831\/revisions"}],"predecessor-version":[{"id":2926,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/2831\/revisions\/2926"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/media\/2927"}],"wp:attachment":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/media?parent=2831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/categories?post=2831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/tags?post=2831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}