Table of Contents
Introduction
Terraform on Google Cloud Platform (GCP) makes infrastructure changes predictable and repeatable. This guide shows a minimal configuration to create a Google Cloud Storage (GCS) bucket using Terraform.
Prerequisites
- A GCP project.
- Google Cloud CLI installed and authenticated (
gcloud auth login). - Terraform installed (
terraform version).
Step 1: Create a Working Folder
Create a new folder and add a main.tf file.
terraform {
required_version = ">= 1.5.0"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 5.0"
}
}
}
provider "google" {
project = "your-gcp-project-id"
region = "europe-west1"
}
Step 2: Create a GCS Bucket
Define a simple storage bucket.
resource "google_storage_bucket" "demo" {
name = "terraformpilot-demo-bucket-12345"
location = "EU"
force_destroy = true
}
Step 3: Initialize and Deploy
Run the standard Terraform workflow:
terraform init
terraform plan
terraform apply
Step 4: Clean Up
Destroy resources to avoid charges:
terraform destroy
Best Practices for Beginners
- Use service accounts for automation.
- Keep state in a remote backend (GCS + locking).
- Parameterize project and region with variables.
Next Steps in the DevOps Chain
After provisioning, continue with configuration and orchestration:
- Configure servers: https://www.ansiblepilot.com
- Orchestrate apps: https://kubernetes.recipes
Related Tutorials
- Terraform providers explained
- Terraform input and output variables
- Terraform commands overview

