main.tf
: The main Terraform configuration filevariables.tf
: The input variables for the Terraform configurationoutputs.tf
: The output variables for the Terraform configurationterraform.tfvars.example
: An example file for the Terraform variablesprovider.tf
: The provider configuration file
git clone
- Go to the Google Cloud Console
- Click on the project dropdown in the top navigation bar
- Click on
New Project
- Enter a project name and click
Create
- Note the project ID for the next step
- Go to the Google Cloud Console
- Click on the project dropdown in the top navigation bar
- Click on
IAM & Admin
- Click on
Service Accounts
- Click on
Create Service Account
- Enter a name and description for the service account
- Click
Create
- Click on
Select a role
and chooseProject > Editor
- Click
Continue
- Click
Done
- Click on the three dots on the right side of the service account row
- Click
Manage keys
- Click
Add key
and chooseCreate new key
- Choose
JSON
and clickCreate
- Save the JSON file to your local machine
- Note the path to the JSON file for the next step
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 |
terraform init
terraform plan
terraform apply
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 |
- Go to the Google Cloud Console
- Click on the project dropdown in the top navigation bar
- Click on
Cloud Run
- Click on the service name
- Click on the service URL to view the service
terraform destroy
- Cloud Run
- Terraform
- Google Cloud SDK
- Google Cloud Console
- Google Cloud API Library
- Google Cloud Service Accounts
- Google Cloud SDK Installation
- Google Cloud SDK Authentication
- Terraform Google Cloud Provider
- Terraform Google Cloud Run
- Terraform Google Cloud Build
- Terraform Google Cloud Service Account
- Terraform Google Cloud IAM Binding
- Terraform Google Cloud IAM Member
- Terraform Google Cloud Project
- Terraform Google Cloud Project Service
- Terraform Google Cloud Project IAM Policy
- Terraform Google Cloud Project Service Identity
- Terraform Google Cloud Project Service Identity Pool