Last active
September 1, 2016 11:12
-
-
Save sean-/0f19442d7a1c8a5ea50ce33bae6a8eb0 to your computer and use it in GitHub Desktop.
FreeBSD 11.0-RC1 on GCE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quick Terraform file to spin up FreeBSD 11.0-RC1 on GCE | |
// | |
// Steps: | |
// 0) Install Terraform >= 0.6.16 <https://www.terraform.io/downloads.html> | |
// 0.1) Install Google SDK if not already done (hint: `which gcloud` must succeed): https://cloud.google.com/sdk/ | |
// 0.2) If already installed, make sure GCE settings are correct by re-running: `gcloud init` | |
// 0.3) Load the correct SSH key into your ssh-agent: `ssh-add ~/.ssh/google_compute_engine` | |
// 1) Drop this file into a dedicated directory | |
// 2) Populate account.json from https://console.cloud.google.com/apis/credentials/serviceaccountkey?authuser=1 | |
// 3) Plan the change by running: `terraform plan -out foo.plan` | |
// 4) Apply the plan by running: `terraform apply foo.plan` | |
// 5) Get the details by running: `terraform show` | |
// 6) SSH into the newly spun-up machine (see assigned_nat_ip): `ssh -p22 104.198.106.9` | |
// 7) Destroy everything in the state file: `terraform destroy` | |
// Get a list of current zones in the given regions. Use a zone name as the region: gcloud compute region list | |
variable "region" { | |
default = "us-west1-a" | |
} | |
variable "project-name" { | |
default = "my-project" | |
} | |
variable "iso-image-org" { | |
// Use FreeBSD from the official FreeBSD repo | |
default = "freebsd-org-cloud-dev" | |
} | |
// Use the latest from FreeBSD. To find out what's available, run: | |
// | |
// $ gcloud compute images list --project freebsd-org-cloud-dev --uri --regexp freebsd'.*' | |
variable "freebsd-version" { | |
default = "freebsd-11-0-rc1-amd64" | |
} | |
provider "google" { | |
credentials = "${file("account.json")}" | |
project = "${var.project-name}" | |
region = "${var.region}" | |
} | |
resource "google_compute_instance" "test" { | |
count = 1 // Adjust as desired | |
name = "test${count.index + 1}" // yields "test1", "test2", etc. It's also the machine's name and hostname | |
machine_type = "f1-micro" // smallest (CPU & RAM) available instance | |
zone = "${var.region}" | |
disk { | |
image = "${var.iso-image-org}/${var.freebsd-version}" | |
} | |
network_interface { | |
network = "default" | |
access_config { | |
// Ephemeral IP - leaving this block empty will generate a new external IP and assign it to the machine | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment