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

Enabling Developers with Terraform

Avatar for Devina Devina
January 30, 2020

Enabling Developers with Terraform

An introduction to Terraform, Sentinel, Vault and Hashicorp Enterprise products.

Not sponsored by HashiCorp, I don't work there, just work with their products.

Avatar for Devina

Devina

January 30, 2020

Other Decks in Programming

Transcript

  1. Context... Security @ Etsy - Open Source Terraform/Open Source Vault

    Security @ Hulu - Terraform Enterprise/Vault Enterprise
  2. Vault Deployment Vault Prod Vault Prod DR Vault Prod PR

    Vault Non-Prod Vault Non-Prod DR Vault Non-Prod PR Vault Sandbox
  3. Vault Deployment Vault Prod Vault Node Vault Node Vault Node

    Consul Node Consul Node Consul Node Consul Node Consul Node =
  4. What is this talk? <3 AWS Meetup & HashiCorp Meetup

    Beginner Level Architecture Gotcha’s
  5. What will we discuss today? • What is Terraform? •

    What is the difference between Terraform & AWS UI • How to program in Terraform ◦ Resources ◦ Modules ◦ ... • Options
  6. Terraform - Terraform is both a programming language & its

    a tool for actioning that code. - Terraform is a tool for building, or changing, or versioning your infrastructure (servers, storage buckets, databases)
  7. Benefits - Cloud Agnostic - Picking one Cloud Provider doesn’t

    dig you into a deep dark hole - Resource types aren’t the same but - the how resources are created is the same
  8. Benefits - Auditability - Security/Compliance - Who made what changes

    in your infrastructure? - Who approved those changes to be made?
  9. TF State - Record of changes - Output data -

    Making changes outside of terraform
  10. Secrets in TF State Gotcha - Outputing IAM Keys in

    TF State will mean that your secrets are in TF State for everyone to read - PGP Encrypt
  11. Drift Gotcha - Creating new things in UI and trying

    to reference them in Terraform - Changing terraform’d infrastructure in the UI.
  12. Using S3 - Coordinate with your team without overwriting your

    state files - Backend becomes s3 - State file locks to prevent collision
  13. What is a workspace? - Directory where your main.tf lives

    - Terraform configurations - Variable Values - State - Credentials & Secrets
  14. Workspaces - Backup State files - Run history - Terraform

    apply - Logs - Terraform Enterprise
  15. Let’s Write some Code - Workspaces - Resources - Providers

    - Modules - Output Statements - Sentinel
  16. Modules - Think Classes/Objects in any OOO language - Parent

    module -> child module - Version controlled
  17. Fun Ideas with Modules - Auto generate module based infrastructure

    using scripts - Great for Documentation - Use Versioning for different versions of api’s
  18. Sentinel - Policy as Code - Define policies to parse

    TF Plan, State & Config - Runs after TF Plan
  19. What did we learn? - Workspaces - Resources - Providers

    - Modules - Output Statements - Sentinel
  20. Terraform Options Open Source Terraform / Enterprise Monolith Repo /

    Some Repos / Many Repos Secrets Management Permission to execute terraform
  21. Open Source Enterprise - Fo Free - Great for small

    teams - Experimentation - Local development - $$$ - Larger companies - Migrations - Sentinel requirements - Secrets Management
  22. One Repo Some Repos Many Repos - Everything has a

    place, you know exactly where to go when you need to look something up - Workspaces are folders in project - Collisions in tfstate highly likely - Everything is organized by team/group/dom ain - Slightly harder for engineers to know where to go - Collisions in tfstate moderately likely - Entirely dependant on whomever wants to create a repo/workspace/etc. - Documentation highly necessary! - Collisions are least likely
  23. External Vault Internal Vault - Difficult to set up -

    Manage all your secrets - Lots of work up front for a bigger payout - Can use this - So So So Easy - Available in TFE - Secrets available in TFState
  24. External Vault Internal Vault - Difficult to set up -

    Manage all your secrets - Lots of work up front for a bigger payout - Can use this - So So So Easy - Available in TFE - Secrets available in TFState Gotcha
  25. Admin Execute Terraform Only - Give Admin executer privileges -

    Developers can write infrastructure code - Admin can approve/deny - Admin can Execute Lots of overhead for Admin - Anyone can write terraform code - Admin can approve/deny code - Developers can use an orchestrator (in house/jenkins) to execute code - No developers are given access to do anything in the UI
  26. RECAP - Vault - Terraform vs UI - Terraform Programming

    Language - Sentinel Policy Language - Choices that are yours to make - Gotcha’s
  27. Shameless Plug #1 Girls Who Code - Ages 12-18 -

    University of Illinois at Chicago - Saturday mornings from 10am - 12pm - Women & Non-Binary engineers wanted! [email protected]