Getting familiar with Terraform
In a previous post I covered the basics of Terraform. In this post I’m going to cover a few more things that I find necessary in most infrastructures I create.
The machines
I’m going to start with a couple of machines:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Configure Google Cloud
provider "google" {
credentials = "${file("credentials.json")}"
project = "ncona-1504"
version = "~> 1.13"
}
// Machines
resource "google_compute_instance" "us-central1-c--f1-micro--001" {
name = "us-central1-c--f1-micro--001"
machine_type = "f1-micro"
zone = "us-central1-c"
boot_disk {
initialize_params {
image = "ubuntu-1604-xenial-v20170815a"
}
}
network_interface {
network = "default"
}
}
resource "google_compute_instance" "us-central1-c--f1-micro--002" {
name = "us-central1-c--f1-micro--002"
machine_type = "f1-micro"
zone = "us-central1-c"
boot_disk {
initialize_params {
image = "ubuntu-1604-xenial-v20170815a"
}
}
network_interface {
network = "default"
}
}