Skip to content

Instantly share code, notes, and snippets.

@tgruben
Created August 19, 2019 12:28
Show Gist options
  • Save tgruben/f74305a2e9b36e48ddef689d90271e9f to your computer and use it in GitHub Desktop.
Save tgruben/f74305a2e9b36e48ddef689d90271e9f to your computer and use it in GitHub Desktop.
// Configure the Google Cloud provider
provider "google" {
credentials = "${file("credentials.json")}"
project = "pilosa-sandbox"
region = "us-central1"
}
// Terraform plugin for creating random ids
resource "random_id" "instance_id" {
byte_length = 8
}
// A single Google Cloud Engine instance
resource "google_compute_instance" "default" {
name = "experiment-${random_id.instance_id.hex}"
machine_type = "n1-standard-32"
zone = "us-central1-c"
boot_disk {
initialize_params {
image = "gce-uefi-images/ubuntu-1804-lts"
}
}
// Use an existing disk resource
scratch_disk {
// Instance Templates reference disks by name, not self link
interface = "NVME"
}
// Make sure flask is installed on all new instances for later steps
metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential python-pip rsync;sudo mkfs.ext4 -F /dev/nvme0n1; sudo mkdir -p /mnt/disks/data1; sudo mount /dev/nvme0n1 /mnt/disks/data1"
network_interface {
network = "default"
access_config {
// Include this section to give the VM an external ip address
}
}
metadata = {
ssh-keys = "ubuntu:${file("~/.ssh/id_rsa.pub")}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment