Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to the Terraform Ecosystem

Intro to the Terraform Ecosystem

In this talk, Tony Carmichael (Product Lead, Terraform OSS Ecosystem at HashiCorp), Taylor Dolezal (Developer Advocate at HashiCorp) and I give an introduction to the Terraform ecosystem.

This version of the presentation was given at an internal meetup in October 2020.

---

Companion Code: github.com/ksatirli/code-quality-for-terraform

Kerim Satirli
PRO

October 26, 2020
Tweet

More Decks by Kerim Satirli

Other Decks in Programming

Transcript

  1. An Introduction to the Terraform Ecosystem

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

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

  4. Taylor Dolezal (He/Him) Developer Advocate at HashiCorp

  5. @onlydole on GitHub and Twitter Developer Advocate at HashiCorp

  6. Kerim Satirli (He/Him) Developer Advocate at HashiCorp

  7. @ksatirli on GitHub and Twitter Developer Advocate at HashiCorp

  8. 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
  9. ⁄ Infrastructure as Code

  10. Infrastructure as Code ▪ executable documentation ▪ enables collaboration ▪

    safe and predictable
  11. ⁄ HashiCorp Terraform

  12. Terraform Providers 135+ Official / Verified Providers Cisco ACI, MSO,

    etc. 360+ Community Providers Auth0, 1Password, Unifi, etc.
  13. Terraform Provider Quality 135+ Official / Verified Providers 360+ Community

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

  15. Terraform Registry 900k Installs per Day 4.2k Community Modules

  16. ⁄ HashiCorp Configuration Language

  17. 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 }
  18. 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 }
  19. ⁄ Terraform-native Code Quality Tools

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

  21. Command: terraform validate TERMINAL > terraform validate Success! The configuration

    is valid.
  22. ⁄ TFLint

  23. TFLint .tflint.hcl rule "terraform_required_providers" { enabled = true } rule

    "terraform_required_version" { enabled = true } rule "terraform_naming_convention" { enabled = true format = "snake_case" }
  24. 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" {
  25. ⁄ pre-commit

  26. 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
  27. Command: pre-commit run TERMINAL > pre-commit run --all-files Terraform fmt............................................Passed

    Terraform validate.......................................Passed
  28. ⁄ GitHub Actions

  29. 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" ...
  30. 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
  31. GitHub Actions hashi.co/tf-code-quality-gha

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

  33. Thank You tcarmichael@hashicorp.com tdolezal@hashicorp.com kerim@hashicorp.com