Skip to content

Instantly share code, notes, and snippets.

@ahmed-abdelazim
Last active July 22, 2019 13:11
Show Gist options
  • Select an option

  • Save ahmed-abdelazim/8a08e0597a66426da0e73bc4b879ec7c to your computer and use it in GitHub Desktop.

Select an option

Save ahmed-abdelazim/8a08e0597a66426da0e73bc4b879ec7c to your computer and use it in GitHub Desktop.
Quick Terraform start

Install Terraform

wget https://releases.hashicorp.com/terraform/0.11.9/terraform_0.11.9_linux_amd64.zip
unzip terraform_0.11.9_linux_amd64.zip
export PATH="$PATH:$HOME/terraform"
cd /usr/bin
sudo ln -s $HOME/terraform
cd $HOME
source ~/.bashrc
terraform
terraform init

Create GCP instance

create terraform file nano instance.tf and then put the following contnent and save

resource "google_compute_instance" "default" {
  project      = "<PROJECT_ID>"
  name         = "terraform"
  machine_type = "n1-standard-1"
  zone         = "us-central1-a"

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

  network_interface {
    network = "default"
    access_config {
    }
  }
}

To see what will happen terraform plan

Then apply changes: terraform apply

To check whar is going: terraform show

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment