Slide 1

Slide 1 text

Taming Infrastructure Workflow at Scale With Terraform https://unsplash.com/photos/-a4tzI2fNW8 Photo by Rita Morais @anubhavm 

Slide 2

Slide 2 text

@anubhavm Anubhav Mishra Developer Advocate, HashiCorp

Slide 3

Slide 3 text

PROVISION, SECURE AND RUN ANY INFRASTRUCTURE Nomad Consul Vault Vagrant Packer Terraform Consul Enterprise Terraform Enterprise Vault Enterprise PRODUCT SUITE OSS TOOL SUITE RUN Applications SECURE Application Infrastructure PROVISION Infrastructure FOR INDIVIDUALS FOR TEAMS Nomad Enterprise

Slide 4

Slide 4 text

Evolution

Slide 5

Slide 5 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER Evolution !5 ~30 years ago

Slide 6

Slide 6 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER Evolution !6 ~20 years ago

Slide 7

Slide 7 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER Evolution !7 ~15-20 years ago

Slide 8

Slide 8 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER Evolution !8 ~10 years ago

Slide 9

Slide 9 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER Evolution !9 VIRTUAL MACHINES ~10 years ago

Slide 10

Slide 10 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER Evolution !10 CONTAINERS VIRTUAL MACHINES ~5 years ago

Slide 11

Slide 11 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER Evolution !11 CONTAINERS VIRTUAL MACHINES ~5 years ago

Slide 12

Slide 12 text

Copyright © 2017 HashiCorp @anubhavm  DATACENTER DNS Evolution !12 DATABASE Presently

Slide 13

Slide 13 text

Copyright © 2017 HashiCorp @anubhavm  DC 1 Evolution !13 DC 2 Presently

Slide 14

Slide 14 text

Copyright © 2017 HashiCorp @anubhavm  Evolution !14 Rise in Complexity

Slide 15

Slide 15 text

Workflow Photo by Daniel Apodaca on Unsplash

Slide 16

Slide 16 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !16 Previously

Slide 17

Slide 17 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !16 BUY Previously

Slide 18

Slide 18 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !16 BUY PROVISION Previously

Slide 19

Slide 19 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !16 BUY PROVISION UPDATE/DESTROY -/+ Previously

Slide 20

Slide 20 text

Copyright © 2017 HashiCorp @anubhavm  BUY Workflow !17 PROVISION UPDATE/DESTROY -/+ Previously

Slide 21

Slide 21 text

Copyright © 2017 HashiCorp @anubhavm  BUY Workflow !17 Previously

Slide 22

Slide 22 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !18 BUY Presently

Slide 23

Slide 23 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !18 BUY Presently

Slide 24

Slide 24 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !19 PROVISION UPDATE/DESTROY -/+ BUY Presently

Slide 25

Slide 25 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !19 PROVISION BUY Presently

Slide 26

Slide 26 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !19 PROVISION Presently

Slide 27

Slide 27 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !19 PROVISION Presently

Slide 28

Slide 28 text

Copyright © 2017 HashiCorp @anubhavm  PROVISION Workflow !20 Presently

Slide 29

Slide 29 text

Copyright © 2017 HashiCorp @anubhavm  PROVISION Workflow !20 Presently

Slide 30

Slide 30 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !21 BUY PROVISION UPDATE/DESTROY -/+ Presently

Slide 31

Slide 31 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !21 UPDATE/DESTROY -/+ Presently

Slide 32

Slide 32 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !22 UPDATE/DESTROY -/+ CLOUD PROVIDER API Presently

Slide 33

Slide 33 text

Copyright © 2017 HashiCorp @anubhavm  Workflow !23 Presently

Slide 34

Slide 34 text

Copyright © 2017 HashiCorp @anubhavm  !24 CDW

Slide 35

Slide 35 text

Copyright © 2017 HashiCorp @anubhavm  !24 CDW

Slide 36

Slide 36 text

Copyright © 2017 HashiCorp @anubhavm  !24 CDW

Slide 37

Slide 37 text

Copyright © 2017 HashiCorp @anubhavm  !25 CDW

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

$ ssh [email protected]
 $ sudo apt-get install default-jre $ echo “the oracle way” $ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer $ ./setup-java.sh Terminal

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

$ aws usage: aws [options] [ ...] [parameters] To see help text, you can run: aws help aws help aws help Terminal

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Why Did We Change? Photo by Maxime Rossignol on Unsplash

Slide 46

Slide 46 text

Copyright © 2017 HashiCorp @anubhavm  !33 Deliver Applications at a Rapid Pace

Slide 47

Slide 47 text

Copyright © 2017 HashiCorp @anubhavm  !34 Deliver Applications at Scale

Slide 48

Slide 48 text

Copyright © 2017 HashiCorp @anubhavm  !35 Single & Unified Workflow for Infrastructure

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

s Copyright © 2017 HashiCorp @anubhavm  Motivation !37 Why Terraform?

Slide 51

Slide 51 text

Copyright © 2017 HashiCorp @anubhavm  Why Terraform? !38 How Do We Provision Resources? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)

Slide 52

Slide 52 text

Copyright © 2017 HashiCorp @anubhavm  Why Terraform? !39 How Do We Manage the Lifecycle of Resources? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)

Slide 53

Slide 53 text

Copyright © 2017 HashiCorp @anubhavm  Why Terraform? !40 How Do We Enforce Policies Across the Resources? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)

Slide 54

Slide 54 text

Copyright © 2017 HashiCorp @anubhavm  Why Terraform? !41 How Do We Automate and Share the Configurations? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)

Slide 55

Slide 55 text

Goal

Slide 56

Slide 56 text

Copyright © 2017 HashiCorp @anubhavm  Goal !43 Provide a Unified Workflow Using Infrastructure as Code to Iterate Over Infrastructure Safely that is Capable of Provisioning Anything Anywhere.

Slide 57

Slide 57 text

Copyright © 2017 HashiCorp @anubhavm  !44 Terminal resource "TYPE" "NAME" { ATTRIBUTES }

Slide 58

Slide 58 text

Copyright © 2017 HashiCorp @anubhavm  !45 Terminal resource "azurerm_virtual_machine" "web" { storage_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "16.04-LTS" version = "latest" } } resource "aws_instance" "web" { ami = "ami-b123125" } main.tf

Slide 59

Slide 59 text

Copyright © 2017 HashiCorp @anubhavm  !46 Terminal resource "azurerm_public_ip" "web" { name = "webserver-ip" location = "West US" resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf

Slide 60

Slide 60 text

Copyright © 2017 HashiCorp @anubhavm  !47 Terminal resource "azurerm_public_ip" "web" { name = "webserver-ip" location = "West US" resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf

Slide 61

Slide 61 text

Copyright © 2017 HashiCorp @anubhavm  !48 Terminal resource "cloudflare_page_rule" "www" { # ... } resource "fastly_service_v1" "myservice" { name = "myawesometestservice" # ... } main.tf

Slide 62

Slide 62 text

Copyright © 2017 HashiCorp @anubhavm  !49 Terminal resource "github_membership" "membership_for_some_user" { username = "admin" role = "owner" } resource "gitlab_project" "example" { name = "example" description = "My awesome codebase" visibility_level = "public" } main.tf

Slide 63

Slide 63 text

Copyright © 2017 HashiCorp @anubhavm  !50 ~100 Terraform Providers

Slide 64

Slide 64 text

Copyright © 2017 HashiCorp @anubhavm  !50

Slide 65

Slide 65 text

Copyright © 2017 HashiCorp @anubhavm  !50

Slide 66

Slide 66 text

Copyright © 2017 HashiCorp @anubhavm  !51 CRUD API =

Slide 67

Slide 67 text

Copyright © 2017 HashiCorp @anubhavm  !52 CRUD API =

Slide 68

Slide 68 text

Copyright © 2017 HashiCorp @anubhavm  !52 CRUD API = Create()

Slide 69

Slide 69 text

Copyright © 2017 HashiCorp @anubhavm  !52 CRUD API = Create() Read()

Slide 70

Slide 70 text

Copyright © 2017 HashiCorp @anubhavm  !52 CRUD API = Create() Read() Update()

Slide 71

Slide 71 text

Copyright © 2017 HashiCorp @anubhavm  !52 CRUD API = Create() Read() Update() Destroy()

Slide 72

Slide 72 text

Copyright © 2017 HashiCorp @anubhavm  !53 Describe Your Infrastructure in Text Files

Slide 73

Slide 73 text

Copyright © 2017 HashiCorp @anubhavm  !54 Human Friendly Configuration

Slide 74

Slide 74 text

Copyright © 2017 HashiCorp @anubhavm  !55 Human Friendly Configuration <3 JSON

Slide 75

Slide 75 text

Copyright © 2017 HashiCorp @anubhavm  !56 Store in Any VCS

Slide 76

Slide 76 text

Copyright © 2017 HashiCorp @anubhavm  !57 Track the History of Your Infrastructure

Slide 77

Slide 77 text

PLAN & APPLY

Slide 78

Slide 78 text

Copyright © 2017 HashiCorp @anubhavm  !59 Terminal resource "azurerm_public_ip" "web" { resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "azurerm_network_interface" "web" { resource_group_name = "webserver-rg" ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = 1 network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { offer = "UbuntuServer" ..... } } resource "dnsimple_record" "web" { domain = "example.com" name = "webs" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf

Slide 79

Slide 79 text

Copyright © 2017 HashiCorp @anubhavm  !60 Terminal resource "azurerm_public_ip" "web" { resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "azurerm_network_interface" "web" { resource_group_name = "webserver-rg" ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = 1 network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { offer = "UbuntuServer" ..... } } resource "dnsimple_record" "web" { domain = "example.com" name = "webs" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf

Slide 80

Slide 80 text

Copyright © 2017 HashiCorp @anubhavm  !61 Terminal $ terraform plan main.tf

Slide 81

Slide 81 text

Copyright © 2017 HashiCorp @anubhavm  !62 “Shows You What Will Happen Before It Actually Happens” TERRAFORM PLAN Anubhav Mishra NDC Oslo 2018

Slide 82

Slide 82 text

Copyright © 2017 HashiCorp @anubhavm  !63 Terminal + azurerm_public_ip.web ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: domain: "example.com" domain_id: hostname: name: "test" priority: ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell

Slide 83

Slide 83 text

Copyright © 2017 HashiCorp @anubhavm  !64 Terminal + azurerm_public_ip.web ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: domain: "example.com" domain_id: hostname: name: "test" priority: ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell

Slide 84

Slide 84 text

Copyright © 2017 HashiCorp @anubhavm  !65 Terminal + azurerm_public_ip.web ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: domain: "example.com" domain_id: hostname: name: "test" priority: ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell

Slide 85

Slide 85 text

Copyright © 2017 HashiCorp @anubhavm  !66 Terminal + azurerm_public_ip.web ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: domain: "example.com" domain_id: hostname: name: "test" priority: ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell

Slide 86

Slide 86 text

Copyright © 2017 HashiCorp @anubhavm  !67 Terminal $ terraform apply shell

Slide 87

Slide 87 text

Copyright © 2017 HashiCorp @anubhavm  !68 Previously?????

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

State

Slide 91

Slide 91 text

Copyright © 2017 HashiCorp @anubhavm  !71 Map of Real World Resources to Your Configuration. TERRAFORM STATE

Slide 92

Slide 92 text

Copyright © 2017 HashiCorp @anubhavm  !72 Terminal { "version": 3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate

Slide 93

Slide 93 text

Copyright © 2017 HashiCorp @anubhavm  !73 Terminal { "version": 3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate

Slide 94

Slide 94 text

Copyright © 2017 HashiCorp @anubhavm  !73 Terminal { "version": 3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate

Slide 95

Slide 95 text

Copyright © 2017 HashiCorp @anubhavm  !73 Terminal { "version": 3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate Storage: file, consul, azurerm, s3, gcs, etc.

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

Collaboration Photo by rawpixel on Unsplash

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

Copyright © 2017 HashiCorp @anubhavm  !77

Slide 101

Slide 101 text

Copyright © 2017 HashiCorp @anubhavm  !78 OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 102

Slide 102 text

Copyright © 2017 HashiCorp @anubhavm  !79 OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 103

Slide 103 text

Copyright © 2017 HashiCorp @anubhavm  !79 OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 104

Slide 104 text

Copyright © 2017 HashiCorp @anubhavm  !79 OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 105

Slide 105 text

Copyright © 2017 HashiCorp @anubhavm  !79 OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 106

Slide 106 text

Copyright © 2017 HashiCorp @anubhavm  !79 OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 107

Slide 107 text

Copyright © 2017 HashiCorp @anubhavm  !80 OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 108

Slide 108 text

Modules

Slide 109

Slide 109 text

Copyright © 2017 HashiCorp @anubhavm  !82 Terminal resource "azurerm_public_ip" "web" { ..... } resource "azurerm_network_interface" "web" { ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = 1 network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "16.04-LTS" version = "latest" } } resource "dnsimple_record" "web" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf

Slide 110

Slide 110 text

Copyright © 2017 HashiCorp @anubhavm  !83 Terminal resource "azurerm_public_ip" "web" { ..... } resource "azurerm_network_interface" "web" { ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = "${var.count}" network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { publisher = "Canonical" offer = "${var.os_name}" sku = "${var.sku}" version = "latest" } } resource "dnsimple_record" "web" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf

Slide 111

Slide 111 text

Copyright © 2017 HashiCorp @anubhavm  !84 Terminal resource "azurerm_public_ip" "web" { ..... } resource "azurerm_network_interface" "web" { ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = "${var.count}" network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { publisher = "Canonical" offer = "${var.os_name}" sku = “${var.sku}" version = "latest" } } resource "dnsimple_record" "web" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf

Slide 112

Slide 112 text

Copyright © 2017 HashiCorp @anubhavm  !85 Terminal module "webserver" { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf

Slide 113

Slide 113 text

Copyright © 2017 HashiCorp @anubhavm  !86

Slide 114

Slide 114 text

Copyright © 2017 HashiCorp @anubhavm  !87 Terminal module "webserver" { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf

Slide 115

Slide 115 text

Copyright © 2017 HashiCorp @anubhavm  !88 Terminal module "webserver" { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf OPERATIONS ENGINEER

Slide 116

Slide 116 text

Copyright © 2017 HashiCorp @anubhavm  !89 Terminal module "webserver" { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf OPERATIONS ENGINEER SOFTWARE ENGINEER

Slide 117

Slide 117 text

Copyright © 2017 HashiCorp @anubhavm  !90 Terminal module "webserver" { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf OPERATIONS ENGINEER SOFTWARE ENGINEER WEBSERVERS

Slide 118

Slide 118 text

INFRASTRUCTURE WORKFLOW FOR THE CLOUD

Slide 119

Slide 119 text

s Copyright © 2017 HashiCorp @anubhavm  !92 DEMO

Slide 120

Slide 120 text

www.hashicorp.com FOR EVERYONE, EVERYWHERE Thank You! I have stickers! Ask me anything. @anubhavm Anubhav Mishra