Skip to content

afeeney9/TerraformCodebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TerraformCodebase

Setup Instructions

  1. Clone the repository

    git clone https://github.com/afeeney9/TerraformCodebase.git
    cd TerraformCodebase
  2. Configure variables

    • Copy terraform.tfvars.example to terraform.tfvars and update values:

      project = "your-gcp-project-id"
      region  = "us-central1"
      zone    = "us-central1-a"
      db_password = "your-db-password"
  3. Initialize Terraform

    terraform init
  4. Review the execution plan

    terraform plan
  5. Apply the configuration

    terraform apply
    • Confirm with yes when prompted.
  6. Deploy the application

    • The VM startup script (cloud-init.sh) will clone the application from Git and start the service.
  7. View Outputs

    terraform output
    • vm_public_ip: Access the web app via this IP.
    • vm_private_ip: VM internal IP.
    • cloud_sql_private_ip: SQL instance private IP.
    • db_connection_name: Cloud SQL connection string.
  8. Destroy the environment

    terraform destroy

Architecture Diagram

flowchart LR
  subgraph VPC [VPC: terraform-network]
    Subnet[gallery-subnet<br/>10.0.0.0/16]
    VM[Compute Instance<br/>e2-standard-2]
    SQL[Cloud SQL<br/>MySQL 8.0]
    Bucket[Google Cloud Storage]
  end

  VM -->|Private IP| SQL
  VM -->|Public IP| Client
  VM -->|Private IP| Bucket
  SQL -.->|Private Service<br/>Peering| VPC
  Firewall[Firewall<br/>80,443,3306] --> VM
  ServiceAccount --> VM
  ServiceAccount --> SQL
Loading

Notes

  • Ensure your public bucket names are globally unique if adding object storage.
  • For production deployments, consider using Terraform Cloud or a CI/CD pipeline.
  • Secure sensitive variables using Secret Manager or environment variables.

For questions or contributions, please open an issue or submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published