Convert Figma logo to code with AI

hashicorp logoterraform-provider-google

Terraform Provider for Google Cloud Platform

2,283
1,718
2,283
1,728

Top Related Projects

The AWS Provider enables Terraform to manage AWS resources.

Terraform provider for Azure Resource Manager

Terraform Kubernetes provider

20,922

Pulumi - Infrastructure as Code in any programming language 🚀

Quick Overview

The terraform-provider-google repository is the official Terraform provider for Google Cloud Platform (GCP). It allows users to manage and provision GCP resources using Terraform's declarative infrastructure-as-code approach. This provider is essential for DevOps engineers and cloud administrators working with GCP infrastructure.

Pros

  • Comprehensive coverage of GCP services and resources
  • Regular updates and maintenance by HashiCorp and Google
  • Extensive documentation and community support
  • Seamless integration with Terraform's ecosystem

Cons

  • Learning curve for users new to Terraform or GCP
  • Occasional lag in supporting new GCP features
  • Complex configurations required for some advanced scenarios
  • Potential for increased costs if not managed carefully

Code Examples

  1. Creating a GCP Compute Engine instance:
resource "google_compute_instance" "example" {
  name         = "example-instance"
  machine_type = "e2-medium"
  zone         = "us-central1-a"

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-10"
    }
  }

  network_interface {
    network = "default"
    access_config {}
  }
}
  1. Setting up a Google Cloud Storage bucket:
resource "google_storage_bucket" "example" {
  name     = "example-bucket"
  location = "US"

  versioning {
    enabled = true
  }

  lifecycle_rule {
    condition {
      age = 30
    }
    action {
      type = "Delete"
    }
  }
}
  1. Creating a Google Cloud SQL instance:
resource "google_sql_database_instance" "example" {
  name             = "example-instance"
  database_version = "MYSQL_8_0"
  region           = "us-central1"

  settings {
    tier = "db-f1-micro"
  }
}

Getting Started

To use the Google Cloud Platform provider with Terraform:

  1. Install Terraform and set up a GCP project.
  2. Configure your GCP credentials.
  3. Create a Terraform configuration file (e.g., main.tf) with the following content:
terraform {
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 4.0"
    }
  }
}

provider "google" {
  project = "your-project-id"
  region  = "us-central1"
}

# Add your resource definitions here
  1. Run terraform init to initialize the provider.
  2. Use terraform plan and terraform apply to manage your GCP resources.

Competitor Comparisons

The AWS Provider enables Terraform to manage AWS resources.

Pros of terraform-provider-aws

  • More comprehensive coverage of AWS services and resources
  • Larger and more active community, resulting in faster issue resolution and feature additions
  • Better documentation and examples for various AWS-specific use cases

Cons of terraform-provider-aws

  • Can be more complex to use due to the vast number of resources and options available
  • May require more frequent updates to keep up with rapidly evolving AWS services

Code Comparison

terraform-provider-aws:

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
  tags = {
    Name = "ExampleInstance"
  }
}

terraform-provider-google:

resource "google_compute_instance" "example" {
  name         = "example-instance"
  machine_type = "e2-micro"
  zone         = "us-central1-a"
  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-10"
    }
  }
}

Both providers offer similar functionality for creating virtual machines, but the syntax and available options differ based on the specific cloud provider's offerings and terminology.

Terraform provider for Azure Resource Manager

Pros of terraform-provider-azurerm

  • More comprehensive coverage of Azure services and features
  • Better integration with Azure-specific concepts like Resource Groups
  • Faster adoption of new Azure features and services

Cons of terraform-provider-azurerm

  • Steeper learning curve due to Azure's complex resource hierarchy
  • Less mature ecosystem compared to Google Cloud Platform
  • More verbose configuration required for some resources

Code Comparison

terraform-provider-azurerm:

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
  name                = "example-network"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  address_space       = ["10.0.0.0/16"]
}

terraform-provider-google:

resource "google_compute_network" "example" {
  name                    = "example-network"
  auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "example" {
  name          = "example-subnetwork"
  ip_cidr_range = "10.0.0.0/16"
  region        = "us-central1"
  network       = google_compute_network.example.id
}

Both providers offer similar functionality for managing cloud resources, but the syntax and structure differ due to the underlying differences in Azure and Google Cloud architectures. The Azure provider requires explicit resource group management, while the Google provider has a flatter resource hierarchy.

Terraform Kubernetes provider

Pros of terraform-provider-kubernetes

  • More flexible and platform-agnostic, allowing management of Kubernetes resources across various cloud providers and on-premises environments
  • Provides deeper integration with Kubernetes-specific features and custom resources
  • Supports a wider range of Kubernetes objects and configurations

Cons of terraform-provider-kubernetes

  • Requires more in-depth knowledge of Kubernetes concepts and architecture
  • May have a steeper learning curve for users not familiar with Kubernetes
  • Less integrated with cloud-specific features and services compared to terraform-provider-google

Code Comparison

terraform-provider-kubernetes:

resource "kubernetes_deployment" "example" {
  metadata {
    name = "example-deployment"
  }
  spec {
    replicas = 3
    selector {
      match_labels = {
        app = "example"
      }
    }
  }
}

terraform-provider-google:

resource "google_container_cluster" "example" {
  name     = "example-cluster"
  location = "us-central1"
  initial_node_count = 3
  node_config {
    machine_type = "e2-medium"
  }
}

The terraform-provider-kubernetes example focuses on deploying a Kubernetes resource, while the terraform-provider-google example creates a Google Kubernetes Engine (GKE) cluster. The kubernetes provider offers more granular control over Kubernetes objects, while the Google provider simplifies GKE cluster management with cloud-specific features.

20,922

Pulumi - Infrastructure as Code in any programming language 🚀

Pros of Pulumi

  • Supports multiple programming languages (Python, JavaScript, Go, etc.), offering more flexibility
  • Provides stronger type checking and IDE support due to use of general-purpose languages
  • Allows for more complex logic and reusable components in infrastructure code

Cons of Pulumi

  • Steeper learning curve for those familiar with declarative IaC tools
  • Smaller ecosystem and community compared to Terraform
  • Potential for introducing programming errors in infrastructure code

Code Comparison

Terraform (Google Provider):

resource "google_compute_instance" "default" {
  name         = "test"
  machine_type = "e2-medium"
  zone         = "us-central1-a"
}

Pulumi (Python):

import pulumi
from pulumi_gcp import compute

instance = compute.Instance("test",
    machine_type="e2-medium",
    zone="us-central1-a"
)

Both examples create a Google Compute Engine instance, but Pulumi uses a general-purpose programming language (Python in this case), while Terraform uses its domain-specific HCL language. Pulumi's approach allows for more complex logic and better integration with existing development workflows, while Terraform's declarative syntax may be simpler for straightforward infrastructure definitions.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Terraform Provider for Google Cloud Platform

The Terraform Google provider is a plugin that allows Terraform to manage resources on Google Cloud Platform. This provider is maintained by the Terraform team at Google and the Terraform team at HashiCorp

This is the google provider, containing generally available features. To use preview features or features at a beta launch stage, you may use the google-beta provider. Refer to the provider versions documentation for more information about how to use google-beta.

Quick Starts

Provider Usage

Please see instructions on how to configure the Google Provider.

Upgrading the provider

The Google provider doesn't upgrade automatically once you've started using it. After a new release you can run

terraform init -upgrade

to upgrade to the latest stable version of the Google provider. See the Terraform website for more information on provider upgrades, and how to set version constraints on your provider.

Developing the provider

This repository is generated by magic-modules. If you wish to work on the provider, you'll need to make changes in magic-modules. Any changes made directly to this repository will likely be overwritten.

For guidance on how to contribute, see our contribution documentation. If you have other development questions we don't cover, please file an issue!