+

Collaborate & share

version control, shared, and collaborated on

Evolve infrastructure

history of infrastructure changes

Automation friendly

CODE = AUTOMATION

Example


provider "google" {
	region =  "europe-west1"
	credentials = "${file("~/path/to/creds.json")}"
}
		
List of Terraform providers

provider "google" {
	region      = "europe-west1"
	credentials = "${file("~/path/to/creds.json")}"
}
resource "google_project" "demo" {
	project_id      = "terraform-${var.user}"
	name            = "Terraform workshop"
	org_id          = "${var.organization_id}"
	billing_account = "${var.billing_account}"
}
Resources for Google provider

provider "google" {
	region      = "europe-west1"
	credentials = "${file("~/path/to/creds.json")}"
}
resource "google_project" "demo" {
	project_id      = "terraform-${var.user}"
	name            = "Terraform workshop"
	org_id          = "${var.organization_id}"
	billing_account = "${var.billing_account}"
}
resource "google_project_services" "apis" {
	project  = "${google_project.demo.project_id}"
	services = ["compute-component.googleapis.com"]
}

resource "google_compute_instance" "vm" {
	project      = "${google_project.demo.project_id}"
	name         = "user-${var.user}-first-vm"
	machine-type = "f1-micro"
	zone         = "europe-west1-b"
	boot_disk {
	  initialize_params {
		image = "debian-cloud/debian-9"
	  }
	}
	network_interface {
	  network = "default"
	  access_config {} # Ephemeral IP
	}
	metadata_startup_script = "echo hi > /terraform_workshop.txt"
	service_account {
	  scopes = ["https://www.googleapis.com/auth/cloud-platform"]
	}
	depends_on = ["google_project_services.apis"]
}

compute instance reference

graph dependency

terraform graph | dot -Tpng > tf_dep_graph.png

Resources

Extra

THANK YOU

and I'm sorry 🙏
If you had to maintain my code
I hope you learned more by maintaining it
than me by writing it

contact

https://bisconti.cloud/

@julienBisconti

Slides made with Reveal.js and hugo-reveal