/terraform_gcp

Create IaC for GCP using Terraform

Primary LanguageHCL

Image of terraform gcp

Terraform GCP

This repo contains sets of simple Terraform IaC for Google Cloud

Description

Service:

  • Terraform - Cloud Agonistic Infrastructure as Code (IaC) service

Cloud Provider:

  • GCP - Cloud Infrastructure Provider on Google Platform

Project Structure

The infrastructure for the project is as defined below.

├── README.md <-------------- This guide to the project.
├── terraform_vm_vpc<------------ Contains terraform code for creating a GCP Virtual Machine and Virtual Private Cloud
└──imgs <------------------ images for README.md

Prereqs

  • A GCP Account and Project Image of Project Creation
  • GCP APIs Enabled:
    • Cloud Resource Manager API, Cloud Compute Engine API, Cloud Storage API, Cloud IAM API, & Cloud Billing Image of API Services
  • GCP Service Account:
    • Role: Project Editor Role
    • Service Account Admin Role: Your Email Address
    • After you create a sercvice account, generate the JSON key Image of API Services
  • Install GCP SDK
    • brew cask install google-cloud-sdk
  • Create a GCP bucket
    • This bucket will hold the terraform state file
    • All buckets must have a unique name
    • Create a folder within the bucket named terraform1

Running the Project

  • Add your json service account key to the root directory
  • Change directory into a folder with terraform code
  • Change the main.tf file to your unique configurations (comments are in the file for guidance)
  • Run the following commands:
    • terraform init: initalizes your working directory
    • terraform plan: shows the execution plan for your infrastructure. Lets you see which resources are being created
    • terraform apply: apply changes to the infrastructure through changes made in the main.tf file