Terraform for GCP Buckets
A simple Terraform configuration for creating a Google Cloud Storage bucket.
Ensure you have authenticated with GCP CLI (gcloud auth application-default login).
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "4.51.0"
}
}
}
provider "google" {
project = "your-gcp-project-id"
region = "us-central1"
}This example creates a standard, multi-regional bucket.
resource "google_storage_bucket" "example_bucket" {
name = "your-unique-bucket-name"
location = "US"
force_destroy = true # Set to false for production
storage_class = "STANDARD"
uniform_bucket_level_access = true
versioning {
enabled = true
}
labels = {
env = "dev"
}
}terraform initterraform planterraform apply