Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1.88 KB

README.md

File metadata and controls

60 lines (42 loc) · 1.88 KB

tf-gcp-infra

This project aims to automate infrastructure provisioning using Terraform and Google Cloud Platform (GCP).

Overview

The infrastructure is defined as code using Terraform, ensuring reproducibility and consistency across environments. It provisions a Virtual Private Cloud (VPC) named webapp-vpc on GCP, along with custom subnetworks and routes for various components of the application.

Infrastructure Details

  • VPC Name: webapp-vpc
  • Subnets:
    • webapp Subnet: CIDR /24, Gateway: 10.0.1.1
    • db Subnet: CIDR /24, Gateway: 10.0.2.1
  • Route:
    • Name: webapp-route
    • Destination IP Range: 0.0.0.0/0
  • Instance:
    • Name vpc
    • image: image name build by packer
    • network - under vpcs created
    • subnetworks - under subnetworks
    • tags: to match the firewall rules
  • FireWall Rules:
    • Allow-App-Port: Allows traffic on specified application port.
    • Deny-SSH: Denies SSH traffic.

Terraform Initialize

Terraform initializes your working directory and prepares it for other Terraform commands such as terraform plan or terraform apply

Terraform Validation

Terraform configurations are validated to ensure correctness and prevent misconfigurations.

Running Terraform Validation

To validate, plan and apply Terraform configurations, run the following command:

terraform init
terraform validate
terraform plan -var-file="values.tfvars file"     
terraform apply -var-file="values.tfvars file" 

Workflow

GitHub Actions workflows are set up to automatically check the Terraform validation status which allows for merging the branch to main.

Prerequisites

Ensure you have the following installed:

  • Terraform
  • Google Cloud SDK (gcloud) for auth

resources

for writing configuration - https://developer.hashicorp.com/terraform/language for creating multiple vpc - https://developer.hashicorp.com/terraform/language/meta-arguments/for_each