• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Terraform GCP Instance

February 3, 2021

Here’s a Terraform script for launching an instance in Google Cloud Platform.

provider "google" {
  project = "project-id"
  region  = "us-central1"
  zone    = "us-central1-a"
}
resource "google_compute_instance" "wiki" {
  name         = "wiki"
  machine_type = "n2-standard-1"
  zone         = "us-central1-a"
  tags         = ["web-server"]
  labels = {
    name        = "wiki"
    environment = "development"
  }
  boot_disk {
    initialize_params {
      image = "centos-7-v20210122"
    }
  }
  network_interface {
    network = "default"
    access_config {
    }
  }
  service_account {
    email  = "service-account@email.com"
    scopes = ["cloud-platform"]
  }
}

provider "google" { project = "project-id" region = "us-central1" zone = "us-central1-a" } resource "google_compute_instance" "wiki" { name = "wiki" machine_type = "n2-standard-1" zone = "us-central1-a" tags = ["web-server"] labels = { name = "wiki" environment = "development" } boot_disk { initialize_params { image = "centos-7-v20210122" } } network_interface { network = "default" access_config { } } service_account { email = "service-account@email.com" scopes = ["cloud-platform"] } }

Here’s a few Terraform commands.

terraform init
terraform plan
terraform apply
terraform destroy

terraform init terraform plan terraform apply terraform destroy

Filed Under: Cloud Tagged With: compute, gcp, google, instance, launch, terraform

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023