[go: up one dir, main page]

Skip to content

This Terraform module sets up a reusable infrastructure foundation for Google Cloud Platform (GCP) projects. It provisions a VPC, subnets, and a Cloud Run service, making it easy to deploy and manage cloud-native applications.

Notifications You must be signed in to change notification settings

PARTH370/terraform-gcp-vpc-cloudrun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Structure

  • main.tf: The main Terraform configuration file
  • variables.tf: The input variables for the Terraform configuration
  • outputs.tf: The output variables for the Terraform configuration
  • terraform.tfvars.example: An example file for the Terraform variables
  • provider.tf : The provider configuration file

Step 1: Clone the repository

git clone

Step 2: Create a new project in Google Cloud Platform

  1. Go to the Google Cloud Console
  2. Click on the project dropdown in the top navigation bar
  3. Click on New Project
  4. Enter a project name and click Create
  5. Note the project ID for the next step

Step 3: Create a new service account

  1. Go to the Google Cloud Console
  2. Click on the project dropdown in the top navigation bar
  3. Click on IAM & Admin
  4. Click on Service Accounts
  5. Click on Create Service Account
  6. Enter a name and description for the service account
  7. Click Create
  8. Click on Select a role and choose Project > Editor
  9. Click Continue
  10. Click Done
  11. Click on the three dots on the right side of the service account row
  12. Click Manage keys
  13. Click Add key and choose Create new key
  14. Choose JSON and click Create
  15. Save the JSON file to your local machine
  16. Note the path to the JSON file for the next step

Step 4: Setup the variables in .tfvars file

cp terraform.tfvars.example terraform.tfvars
Name Description Type Default Required
gcp_svc_key Path to the service account key file string n/a yes
gcp_project The ID of the project in which resources will be managed string n/a yes
gcp_region The region in which resources will be created string n/a yes
vpc_name The name of the VPC to create string n/a yes
vpc_cidr The CIDR block for the VPC string n/a yes
subnet_cidrs List of subnet CIDR ranges list(string) n/a yes
service_name Name of the Cloud Run service string n/a yes
container_image Container image to deploy string n/a yes
memory_limit Memory limit for the Cloud Run service n/a n/a yes

Step 5: Initialize Terraform

terraform init

Step 6: Plan the Terraform configuration

terraform plan

Step 7: Apply the Terraform configuration

terraform apply

Output

Name Description
vpc_network_name The name of the VPC network
subnet_names The names of the subnets
service_name The name of the Cloud Run service
service_url The URL of the Cloud Run service
vpc_access_connector_name The name of the VPC access connector

Step 8: Test the Cloud Run service

  1. Go to the Google Cloud Console
  2. Click on the project dropdown in the top navigation bar
  3. Click on Cloud Run
  4. Click on the service name
  5. Click on the service URL to view the service

Step 9: Cleanup

terraform destroy

Resources

About

This Terraform module sets up a reusable infrastructure foundation for Google Cloud Platform (GCP) projects. It provisions a VPC, subnets, and a Cloud Run service, making it easy to deploy and manage cloud-native applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages