Building GCP Infrastructure with Terraform and the Power of AI: A ChatGPT-Powered Guide

 Building GCP Infrastructure with Terraform and the Power of AI: A ChatGPT-Powered Guide


This blog aims to provide a simple guide on utilizing GCP infrastructure with Terraform while leveraging the assistance of an AI tool called ChatGPT. If you are new to GCP and starting your journey as a beginner, this blog will help you understand the implementation of a Compute Engine deployed in a public subnet.

Prerequisites:

- A basic understanding of Google Cloud services

- Knowledge of Infrastructure as Code (IAC) and how Terraform facilitates infrastructure building

- Access to a free GCP account and ChatGPT.

Steps:

1. Create a GCP service account using gcloud.

2. Compile a list of Terraform scripts suitable for constructing a small-scale infrastructure.

3. Execute Terraform commands from the cloud shell to implement the infrastructure.

Creating a Service Account Using the gcloud Command:


Log in to GCP cloud account and activate cloud shell terminal under any project 
Create one directory from where you are going to execute your terraform scripts  











Get help from chat gcp to create service account 

Nope open  Open Chant GCP to get gcould command to create  Service account  for your GCP project 

Provide gcloud command to create service account name "my-first-service-account" with role to create network and compute engine 




































Copy it from Chat GCP and execute in your gcloud shell  
































Check from IAM and Admin from  Project  GCP console 























Generate  json key   of service account and download it 
















Upload the same json file or create new json file with copy the same contains 














Ask ChatGPT to provide terraform scrips 










Copy the scrips  and create files using vi command






Now lets check the error with ChatGPT.






Copy the same to main.tf and execute with terraform init 








Then execute 

terraform validate 
terraform plan 
Terraform apply 
  it will ask for YES …

4 objects will be created
- VPC
-Subnets
-Compute engine 
Check it from console 





















 






 





















Comments