Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Copyright © 2020 HashiCorp Understanding Infrastructure as Code with Terraform

Slide 3

Slide 3 text

Agenda

Slide 4

Slide 4 text

Agenda Infrastructure as Code what is it?

Slide 5

Slide 5 text

Agenda Infrastructure as Code what is it? Introduction to Terraform putting the pieces together

Slide 6

Slide 6 text

Agenda Infrastructure as Code what is it? Introduction to Terraform putting the pieces together Terraform Lifecycle and State expanding your knowledge

Slide 7

Slide 7 text

Infrastructure as Code

Slide 8

Slide 8 text

Infrastructure

Slide 9

Slide 9 text

Infrastructure as Code

Slide 10

Slide 10 text

Infrastructure as Code ▪ executable documentation

Slide 11

Slide 11 text

Infrastructure as Code ▪ executable documentation ▪ enables collaboration

Slide 12

Slide 12 text

Infrastructure as Code ▪ executable documentation ▪ enables collaboration ▪ safe and predictable

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

HashiCorp Configuration Language

Slide 15

Slide 15 text

HashiCorp Configuration Language

Slide 16

Slide 16 text

HashiCorp Configuration Language CODE EDITOR

Slide 17

Slide 17 text

HashiCorp Configuration Language CODE EDITOR service { key = "value" }

Slide 18

Slide 18 text

HashiCorp Configuration Language CODE EDITOR service { key = "value" }

Slide 19

Slide 19 text

HashiCorp Configuration Language CODE EDITOR

Slide 20

Slide 20 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { }

Slide 21

Slide 21 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { }

Slide 22

Slide 22 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" }

Slide 23

Slide 23 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } }

Slide 24

Slide 24 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } }

Slide 25

Slide 25 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } }

Slide 26

Slide 26 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } }

Slide 27

Slide 27 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } }

Slide 28

Slide 28 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } } variable "port" { }

Slide 29

Slide 29 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } } variable "port" { description = "Port for web_proxy" default = 8080 }

Slide 30

Slide 30 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } } variable "port" { description = "Port for web_proxy" default = 8080 }

Slide 31

Slide 31 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } } variable "port" { description = "Port for web_proxy" default = 8080 }

Slide 32

Slide 32 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } } variable "port" { description = "Port for web_proxy" default = 8080 }

Slide 33

Slide 33 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "server" { command = ["proxy-app", "server"] } } variable "port" { description = "Port for web_proxy" default = 8080 }

Slide 34

Slide 34 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:${var.port}" process "server" { command = ["proxy-app", "server"] } } variable "port" { description = "Port for web_proxy" default = 8080 }

Slide 35

Slide 35 text

HashiCorp Configuration Language CODE EDITOR service "http" "web_proxy" { listen_addr = "127.0.0.1:${var.port}" process "server" { command = ["proxy-app", "server"] } } variable "port" { description = "Port for web_proxy" default = 8080 }

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Introducing Terraform

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Terraform

Slide 41

Slide 41 text

Terraform 125+ Official Providers AWS, GCP, OpenNebula, etc.

Slide 42

Slide 42 text

Terraform 125+ Official Providers AWS, GCP, OpenNebula, etc. 175+ Community Providers Auth0, Domino’s Pizza etc.

Slide 43

Slide 43 text

First Steps

Slide 44

Slide 44 text

Command: terraform init TERMINAL >

Slide 45

Slide 45 text

Command: terraform init TERMINAL > terraform init

Slide 46

Slide 46 text

Command: terraform init TERMINAL > terraform init Initializing the backend... Initializing provider plugins... - Checking for available provider plugins... - Downloading plugin for provider "aws" (terraform-providers/aws) 2.65.0...

Slide 47

Slide 47 text

Command: terraform init TERMINAL > terraform init Initializing the backend... Initializing provider plugins... - Checking for available provider plugins... - Downloading plugin for provider "aws" (terraform-providers/aws) 2.65.0... Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.

Slide 48

Slide 48 text

Command: terraform plan TERMINAL >

Slide 49

Slide 49 text

Command: terraform plan TERMINAL > terraform plan -out="aws.tfplan"

Slide 50

Slide 50 text

Command: terraform plan TERMINAL > terraform plan -out="aws.tfplan" Terraform will perform the following actions: # aws_instance.open_nebula will be created + resource "aws_instance" "open_nebula" Plan: 1 to add, 0 to change, 0 to destroy. This plan was saved to: aws.tfplan

Slide 51

Slide 51 text

Command: terraform plan TERMINAL > terraform plan -out="aws.tfplan" Terraform will perform the following actions: # aws_instance.open_nebula will be created + resource "aws_instance" "open_nebula" Plan: 1 to add, 0 to change, 0 to destroy. This plan was saved to: aws.tfplan

Slide 52

Slide 52 text

Command: terraform apply TERMINAL > terraform apply "aws.tfplan"

Slide 53

Slide 53 text

Command: terraform apply TERMINAL > terraform apply "aws.tfplan" aws_instance.open_nebula: Creating...

Slide 54

Slide 54 text

Command: terraform apply TERMINAL > terraform apply "aws.tfplan" aws_instance.open_nebula: Creating... aws_instance.open_nebula: Still creating... [10s elapsed]

Slide 55

Slide 55 text

Command: terraform apply TERMINAL > terraform apply "aws.tfplan" aws_instance.open_nebula: Creating... aws_instance.open_nebula: Still creating... [10s elapsed] aws_instance.open_nebula: Still creating... [20s elapsed] aws_instance.open_nebula: Creation complete after 22s Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Slide 56

Slide 56 text

Command: terraform output TERMINAL >

Slide 57

Slide 57 text

Command: terraform output TERMINAL > terraform output

Slide 58

Slide 58 text

Command: terraform output TERMINAL > terraform output volume_device_name = /dev/sdh

Slide 59

Slide 59 text

Command: terraform output TERMINAL > terraform output volume_device_name /dev/sdh

Slide 60

Slide 60 text

Command: terraform destroy TERMINAL

Slide 61

Slide 61 text

Command: terraform destroy TERMINAL > terraform plan -destroy -out="aws.tfplan"

Slide 62

Slide 62 text

Command: terraform destroy TERMINAL > terraform plan -destroy -out="aws.tfplan"

Slide 63

Slide 63 text

Command: terraform destroy TERMINAL > terraform plan -destroy -out="aws.tfplan"

Slide 64

Slide 64 text

Command: terraform destroy TERMINAL > terraform apply "aws.tfplan"

Slide 65

Slide 65 text

Command: terraform destroy TERMINAL > terraform apply "aws.tfplan" aws_ebs_volume.open_nebula: Destroying... aws_instance.open_nebula: Destroying... aws_volume_attachment.open_nebula: Destroying…

Slide 66

Slide 66 text

Command: terraform destroy TERMINAL > terraform apply "aws.tfplan" aws_ebs_volume.open_nebula: Destroying... aws_instance.open_nebula: Destroying... aws_volume_attachment.open_nebula: Destroying… Apply complete! Resources: 0 added, 0 changed, 3 destroyed.

Slide 67

Slide 67 text

Command: terraform fmt TERMINAL

Slide 68

Slide 68 text

Command: terraform fmt TERMINAL > terraform fmt main.tf

Slide 69

Slide 69 text

Command: terraform fmt TERMINAL > terraform fmt main.tf

Slide 70

Slide 70 text

Command: terraform validate TERMINAL > terraform fmt main.tf > terraform validate Success! The configuration is valid.

Slide 71

Slide 71 text

Command: terraform validate TERMINAL > terraform fmt main.tf > terraform validate Success! The configuration is valid.

Slide 72

Slide 72 text

Command: terraform help TERMINAL > terraform help Usage: terraform [-version] [-help] [args] The available commands for execution are listed below. The most common, useful commands are shown first, followed by less common or more advanced commands. Common commands: apply Builds or changes infrastructure destroy Destroy Terraform-managed infrastructure fmt Rewrites config files to canonical format output Read an output from a state file

Slide 73

Slide 73 text

Terraform Lifecycle and State

Slide 74

Slide 74 text

Terraform lifecycle

Slide 75

Slide 75 text

Terraform lifecycle ▪ terraform init

Slide 76

Slide 76 text

Terraform lifecycle ▪ terraform init ▪ terraform fmt

Slide 77

Slide 77 text

Terraform lifecycle ▪ terraform init ▪ terraform fmt ▪ terraform validate

Slide 78

Slide 78 text

Terraform lifecycle ▪ terraform init ▪ terraform fmt ▪ terraform validate ▪ terraform plan

Slide 79

Slide 79 text

Terraform lifecycle ▪ terraform init ▪ terraform fmt ▪ terraform validate ▪ terraform plan -out=“aws.tfplan"

Slide 80

Slide 80 text

Terraform lifecycle ▪ terraform init ▪ terraform fmt ▪ terraform validate ▪ terraform plan -out=“aws.tfplan" ▪ terraform apply "aws.tfplan"

Slide 81

Slide 81 text

Terraform lifecycle ▪ terraform init ▪ terraform fmt ▪ terraform validate ▪ terraform plan -out="aws.tfplan" ▪ terraform apply “aws.tfplan" ▪ terraform plan -destroy

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

Terraform State ▪ maps real-world resources to your configuration

Slide 84

Slide 84 text

Terraform State ▪ maps real-world resources to your configuration ▪ keeps track of (resource) metadata

Slide 85

Slide 85 text

Terraform State ▪ maps real-world resources to your configuration ▪ keeps track of (resource) metadata ▪ improves performance for large infrastructures

Slide 86

Slide 86 text

Terraform State ▪ maps real-world resources to your configuration ▪ keeps track of (resource) metadata ▪ improves performance for large infrastructures ▪ stored locally (by default), can be stored remotely

Slide 87

Slide 87 text

Terraform State ▪ maps real-world resources to your configuration ▪ keeps track of (resource) metadata ▪ improves performance for large infrastructures ▪ stored locally (by default), can be stored remotely

Slide 88

Slide 88 text

Review

Slide 89

Slide 89 text

Review ▪ Infrastructure as Code

Slide 90

Slide 90 text

Review ▪ Infrastructure as Code ▪ Introduction to Terraform

Slide 91

Slide 91 text

Review ▪ Infrastructure as Code ▪ Introduction to Terraform ▪ Terraform Lifecycle and State

Slide 92

Slide 92 text

Materials ▪ slides: hashi.co/open-nebula-slides

Slide 93

Slide 93 text

Materials ▪ slides: hashi.co/open-nebula-slides ▪ guides: hashi.co/tf-learn

Slide 94

Slide 94 text

Get Started with Terraform Cloud

Slide 95

Slide 95 text

Thank You [email protected]