This repository contains Terraform configuration files for setting up infrastructure on Google Cloud Platform (GCP) using Terraform.
Before you begin, make sure you have the following prerequisites installed and configured:
- Terraform: Install Terraform by following the instructions here.
- Google Cloud Platform Account: You need a GCP account to create resources. If you don't have one, sign up here.
- Service Account: Create a service account and download the JSON key file. This service account should have sufficient permissions to create and manage resources on GCP. Refer to the official documentation for instructions.
- Authentication: Authenticate Terraform with GCP using the service account key file. You can do this by setting the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable to the path of the JSON key file.
- gcloud auth application-default login
- gcloud auth application-default revoke
Follow these steps to set up the infrastructure using Terraform:
-
Clone the Repository:
git clone git@github.com:Sourabh-Kumar7/tf-gcp-infra.git
-
Change Directory:
cd tf-gcp-infra/terraform -
Initialize Terraform:
terraform init
-
Review Configuration and Validate Terraform:
Review the
variables.tfvarsfile and update the variables with appropriate values for your environment.terraform validate
-
Plan the Deployment:
terraform plan -var-file="variables.tfvars"This step will show you the execution plan without actually deploying the infrastructure.
-
Deploy Infrastructure:
terraform apply -var-file="variables.tfvars"Confirm the deployment by typing
yeswhen prompted. -
Verify Deployment:
After Terraform has finished applying changes, verify that the infrastructure has been created as expected in your GCP console.
-
Destroy Infrastructure (Optional):
If you want to tear down the infrastructure, you can do so by running:
terraform destroy
Confirm the destruction by typing
yeswhen prompted.
- BigQuery API
- BigQuery Migration API
- BigQuery Storage API
- Cloud Datastore API
- Cloud Logging API
- Cloud Monitoring API
- Cloud SQL
- Cloud Storage
- Cloud Storage API
- Cloud Trace API
- Google Cloud APIs
- Google Cloud Storage JSON API
- Service Management API
- Service Usage API
- Compute Engine API
- Cloud SQL Admin API
- Service Networking API
- Name: my-vpc
- Auto-create Subnets: Disabled
- Routing Mode: Regional
- Default Routes: No default routes created
- Webapp Subnet:
- Name: webapp-subnet
- CIDR Range: 10.1.0.0/24
- Purpose: Subnet for hosting the web application.
- Database (DB) Subnet:
- Name: db-subnet
- CIDR Range: 10.2.0.0/24
- Purpose: Subnet for hosting the database.
- Webapp Route:
- Destination: 0.0.0.0/0
- Next Hop: Internet Gateway
- Priority: 1000
- Tags: webapp
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request.
This project is licensed under the MIT License.