Slide 1

Slide 1 text

Senior Developer - Production Operations and Delivery @anubhavm Taming Terraform Workflow Anubhav Mishra Using Terraform Modules and Github

Slide 2

Slide 2 text

Anubhav Mishra @anubhavm

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Talk ● Terraform at Hootsuite ● Use of Terraform Modules (Dev <--> Ops) ● Atlantis - Hootsuite’s Terraform Workflow ● Live Demo

Slide 6

Slide 6 text

Terraform at Hootsuite

Slide 7

Slide 7 text

Numbers ● 100+ developers ● 20+ microservices ● 2 cluster schedulers ● 1000+ servers ● 1000s of AWS resources

Slide 8

Slide 8 text

Timeline ● Mid 2015 - First Terraform Repo (v1) ● Starting 2016 - Terraform (v2) ● End of 2016 - Terraform “Advanced” Workflow

Slide 9

Slide 9 text

Before Terraform

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

What is Terraform? ● Terraform allows you to manage, build and visualize your infrastructure as code

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

First Attempt

Slide 18

Slide 18 text

First Attempt

Slide 19

Slide 19 text

First Attempt

Slide 20

Slide 20 text

First Attempt staging != production

Slide 21

Slide 21 text

Terraform State

Slide 22

Slide 22 text

First Attempt

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Problems with our first attempt ● Environment drift ● One massive state for every environment ● Hard to collaborate on infrastructure

Slide 25

Slide 25 text

Problems with our first attempt ● Environment drift ● One massive state for every environment ● Hard to collaborate on infrastructure

Slide 26

Slide 26 text

Terraform Version 2 (Second Attempt)

Slide 27

Slide 27 text

Terraform Version 2 (Second Attempt)

Slide 28

Slide 28 text

Terraform Version 2 (Second Attempt)

Slide 29

Slide 29 text

Problems with our first attempt ● Environment drift ● One massive state for every environment ● Hard to collaborate on infrastructure

Slide 30

Slide 30 text

Problems with our first attempt ● Environment drift ● One massive state for every environment ● Hard to collaborate on infrastructure

Slide 31

Slide 31 text

Terraform Version 2 (Second Attempt) terraform.tfstate { "version": 3, "terraform_version": "0.8.8", "serial": 175, "lineage": "2cb11085-2e4e-40ff-bf81-e4ddf8bc8d5d", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { ....

Slide 32

Slide 32 text

Terraform Version 2 (Second Attempt) terraform.tfstate { "version": 3, "terraform_version": "0.8.8", "serial": 175, "lineage": "2cb11085-2e4e-40ff-bf81-e4ddf8bc8d5d", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { ....

Slide 33

Slide 33 text

Terraform Version 2 (Second Attempt) terraform.tfstate

Slide 34

Slide 34 text

Terraform Version 2 (Second Attempt)

Slide 35

Slide 35 text

Terraform Version 2 (Second Attempt)

Slide 36

Slide 36 text

Terraform Version 2 (Second Attempt)

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

terraform.tfstate { "version": 3, "terraform_version": "0.8.8", "serial": 1, "lineage": "9e42c0ac-9e73-4910-8859-504934f2b499", "backend": { "type": "s3", "config": { "bucket": "terraform", "key": "foo-bar", "region": "us-east-1" }, .... "outputs": {}, "resources": { "null_resource.hello": { "type": "null_resource", "depends_on": [], "primary": { "id": "792399369485920658", "attributes": { "id": "792399369485920658" }, "meta": {}, ....

Slide 39

Slide 39 text

stash

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Problems with our first attempt ● Environment drift ● One massive state for every environment ● Hard to collaborate on infrastructure

Slide 44

Slide 44 text

Problems with our first attempt ● Environment drift ● One massive state for every environment ● Hard to collaborate on infrastructure

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

module.server Let me make a generic server module I need 2 servers. Now! Terraform Version 2 (Second Attempt)

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Terraform Version 2 (Second Attempt)

Slide 51

Slide 51 text

Terraform Version 2 (Second Attempt)

Slide 52

Slide 52 text

Inputs Output

Slide 53

Slide 53 text

Terraform Version 2 (Second Attempt)

Slide 54

Slide 54 text

Terraform Version 2 (Second Attempt)

Slide 55

Slide 55 text

Terraform Version 2 (Second Attempt)

Slide 56

Slide 56 text

Terraform Version 2 (Second Attempt)

Slide 57

Slide 57 text

Terraform Version 2 (Second Attempt) 139 Repositories

Slide 58

Slide 58 text

● Multi Environment Terraform Projects ● Isolated Terraform States for Services ○ Smaller Failure Domain ○ Rapid Iteration on Infrastructure ● Use of Terraform Modules ○ Environment Parity ○ Increased Collaboration Between Ops and Dev

Slide 59

Slide 59 text

Are we all done?

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

How do we continue to move fast while we add people?

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

atlantis A unified workflow for collaborating on Terraform through GitHub. https://github.com/hootsuite/atlantis

Slide 66

Slide 66 text

Demo

Slide 67

Slide 67 text

● atlantis - https://github.com/hootsuite/atlantis ● cfgmgmtcamp-atlantis-demo - https://github.com/anubhavmishra/cfgmgmtcamp-atlantis-demo Links

Slide 68

Slide 68 text

Thank You! Senior Developer - Production Operations and Delivery @anubhavm Anubhav Mishra