DEV Community

aravind-dussani99
aravind-dussani99

Posted on

1

Configure terraform with GCP

Context:
Will configure the terraform with GCP in this post.

Steps:

  1. Integrate terraform with GCP
  2. Enable the required GCP APIs
  3. Create a VPC and Subnet

Integrate terraform with GCP:

There are multiple ways to authenticate with GCP like gcloud auth or service account& key. Will use gcloud auth in this post.

We would be using the below mentioned information in this post.

Terraform resources:
1. Terraform block
2. Google, google-beta Provider
3. API enable resource
4. Network, Subnetwork resources

GCP information:
1. ProjectId
2. Region

*Gcloud auth: *

Create the provider.tf with google provider and required version and run the gcloud auth login.

authenticateterraformwithgcp

Proceed for further steps to authenticate terraform with GCP.

allowgoogleauthlibrary

Enable the required GCP APIs:

Will use the google_service_project resource to enable the required iam, workstation apis.

enable apis

Create a VPC and Subnet:

Use the mentioned google_compute_network , google_compute_subnetwork terraform resources to create the VPC and subnets in given gcp project.

terraformvpcsubnet

Resources - References:

Final words:

Feel free to comment your queries here or at LinkedIn . Thanks.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay