Slide 1

Slide 1 text

An Introduction to the Terraform Ecosystem

Slide 2

Slide 2 text

Tony Carmichael (He/Him) Product Lead, Terraform OSS Ecosystem

Slide 3

Slide 3 text

@aicarmic on GitHub and Twitter Product Lead, Terraform OSS Ecosystem

Slide 4

Slide 4 text

Taylor Dolezal (He/Him) Developer Advocate at HashiCorp

Slide 5

Slide 5 text

@onlydole on GitHub and Twitter Developer Advocate at HashiCorp

Slide 6

Slide 6 text

Kerim Satirli (He/Him) Developer Advocate at HashiCorp

Slide 7

Slide 7 text

@ksatirli on GitHub and Twitter Developer Advocate at HashiCorp

Slide 8

Slide 8 text

Agenda Infrastructure as Code Declarative, machine-readable definition files HashiCorp Terraform Safely and predictably make infrastructure changes HashiCorp Configuration Language Concise description of infrastructure Code Quality The good, bad, and the lint-able

Slide 9

Slide 9 text

⁄ Infrastructure as Code

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

⁄ HashiCorp Terraform

Slide 12

Slide 12 text

Terraform Providers 135+ Official / Verified Providers Cisco ACI, MSO, etc. 360+ Community Providers Auth0, 1Password, Unifi, etc.

Slide 13

Slide 13 text

Terraform Provider Quality 135+ Official / Verified Providers 360+ Community Providers

Slide 14

Slide 14 text

Terraform Registry https://registry.terraform.io/

Slide 15

Slide 15 text

Terraform Registry 900k Installs per Day 4.2k Community Modules

Slide 16

Slide 16 text

⁄ HashiCorp Configuration Language

Slide 17

Slide 17 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 18

Slide 18 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 19

Slide 19 text

⁄ Terraform-native Code Quality Tools

Slide 20

Slide 20 text

Command: terraform fmt TERMINAL > terraform fmt provider.tf terraform.tf

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

⁄ TFLint

Slide 23

Slide 23 text

TFLint .tflint.hcl rule "terraform_required_providers" { enabled = true } rule "terraform_required_version" { enabled = true } rule "terraform_naming_convention" { enabled = true format = "snake_case" }

Slide 24

Slide 24 text

Command: tflint TERMINAL > tflint 1 issue(s) found: Warning: data "google_projects" "projects" is declared but not used (terraform_unused_declarations) on data-sources.tf line 11: 11: data "google_projects" "projects" {

Slide 25

Slide 25 text

⁄ pre-commit

Slide 26

Slide 26 text

pre-commit .pre-commit-config.yaml --- fail_fast: true minimum_pre_commit_version: "2.6.0" repos: - repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.31.0 hooks: - id: terraform_fmt - id: terraform_validate

Slide 27

Slide 27 text

Command: pre-commit run TERMINAL > pre-commit run --all-files Terraform fmt............................................Passed Terraform validate.......................................Passed

Slide 28

Slide 28 text

⁄ GitHub Actions

Slide 29

Slide 29 text

GitHub Actions .github/workflows/terraform.yml --- name: "Code Quality: Terraform" on: push: pull_request: env: # `AWS_REGION` must be specified for `terraform validate` AWS_REGION: "xx-xxxx-0" ...

Slide 30

Slide 30 text

GitHub Actions .github/workflows/terraform.yml ... - name: Run `terraform fmt` run: terraform fmt -diff -check -no-color -recursive - name: Run `terraform init` run: terraform init - name: Run `terraform validate` run: terraform validate -no-color

Slide 31

Slide 31 text

GitHub Actions hashi.co/tf-code-quality-gha

Slide 32

Slide 32 text

Materials ▪ slides: hashi.co/tf-ecosystem-intro ▪ code: hashi.co/tf-code-quality-code ▪ forums: discuss.hashicorp.com

Slide 33

Slide 33 text