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

Scaling with Terraform

Scaling with Terraform

HashiCorp Terraform has grown to become a staple amongst the Global 2000 for managing cloud infrastructure. With over 100 distinct providers, Terraform allows users to safely and predictably build, change, and version their infrastructure with ease, all while scaling with your team. In this talk, Clint invites you on a journey of scaling with Terraform-- from the very first user to the very first team, and then onward and upward to large-scale adoption across an enterprise. No matter what stage you're at, Terraform is with you.

Clint Shryock

June 28, 2018
Tweet

More Decks by Clint Shryock

Other Decks in Technology

Transcript

  1. s Copyright © 2018 HashiCorp Hello! !2 Clint Shryock Lead

    Terraform Engineer Hello I'm Clint, long time Terraform developer SEGUE >> Today I'll be talking about…
  2. s Copyright © 2018 HashiCorp Scaling with Terraform !3 The

    Journey from Startup to Enterprise <<Title>> Story from first user, first team, all the way up to full adoption
  3. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage Next !4 The Journey from Startup to Enterprise 4 Part structure to this talk Then we’ll look at things to come
  4. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage Next !5 The Journey from Startup to Enterprise Introduction done, let’s move on
  5. s Copyright © 2018 HashiCorp What is Terraform? !6 Quick

    refresher on what Terraform is and how it fits into the HashiCorp ecosystem To help understand Terraforms mission, we first explain HashiCorp’s mission
  6. Copyright © 2018 HashiCorp Scaling with Terraform !7 The Journey

    from Startup to Enterprise SEGUE>> To do that…
  7. Copyright © 2018 HashiCorp Scaling with Terraform !8 The Journey

    from Startup to Enterprise At HashiCorp we’ve developed a suite of unix like tools Each providing a specific set of functionality
  8. Copyright © 2018 HashiCorp Scaling with Terraform !9 The Journey

    from Startup to Enterprise Our tools can loosely be put in 2 categories, Provisioning and Runtime tools
  9. Copyright © 2018 HashiCorp Scaling with Terraform !10 The Journey

    from Startup to Enterprise Terraform is one of the Provisioning tools SEGUE:: Terraforms mission statement: Write, Plan, and Create Infrastructure as Code
  10. Copyright © 2018 HashiCorp Scaling with Terraform !11 The Journey

    from Startup to Enterprise See? Says so right there ^ Terraform is a command line tool With Terraform you: Write declarative configuration with HCL Terraform uses that configuration to generate plans of change, to safely create infrastructure to match SEGUE:: To do that, HashiCorp Engineers and the Open Source community have created numerous Providers
  11. Copyright © 2018 HashiCorp Scaling with Terraform !12 The Journey

    from Startup to Enterprise This is a very small subset • Support for each is distinct and unique, as opposed to generic • Easily compose multiple tiers/services in configuration (IaaS to PaaS to SaaS) • With Terraform you get a single, consistent workflow, for many clouds
  12. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage Next !13 The Journey from Startup to Enterprise Now we know what Terraform is and does
  13. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage Next !14 The Journey from Startup to Enterprise That part done [[SEGUE]] let’s move on
  14. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage 1: ▪Stage 2: ▪Stage 3: ▪Stage 4: ▪Stage Next !16 The Journey from Startup to Enterprise Says so right there ^ SEGUE:: The first stage I’m sure we all know well
  15. Copyright © 2018 HashiCorp Scaling with Terraform !18 Manual Stage

    ▪Web Consoles ▪Single environment(s) ▪Mutable Infrastructure ▪Infrastructure as Code Using web consoles heavily: point-and-click, using each console separately • May have some custom scripting with CLIs Single environments: Twin Environments or Sibling environments: common ancestry but they can vary in detail a lot Mutable: canonical example is provisioning and instance to serve a role, it’s manually configured over SSH. These are sometimes called “pet servers”, you give them a name and you become emotionally attached to them [[SEGUE]]: And then finally you have Infra as code…wait
  16. Copyright © 2018 HashiCorp Scaling with Terraform !19 Manual Stage

    ▪Web Consoles ▪Single environment(s) ▪Mutable Infrastructure ▪Infrastructure as Code No, no infrastructure as code yet.
  17. Copyright © 2018 HashiCorp Scaling with Terraform !20 Manual Stage

    ▪Web Consoles ▪Single environment(s) ▪Mutable Infrastructure ▪Infrastructure as Code ops.txt Ops.txt: • I've done this! • It is the text file of truth with all information • Or worse, it's all in your head SEGUE: Let’s look at how we’re using Terraform at this stage…
  18. Copyright © 2018 HashiCorp Scaling with Terraform !21 Manual Stage

    ▪ … We’re not There is no Terraform usage in Manual stage. Why is this a stage? SEGUE:: Because “Not using any Terraform is the first step to using a lot of Terraform”
  19. Copyright © 2018 HashiCorp Scaling with Terraform !22 Manual Stage

    ▪Not using any Terraform is the first step to using a lot of Terraform It says so right there ^ In the journey of using and adopting Terraform this is a common starting point, whether you're a startup or massive Enterprise, you established infrastructure or just getting started
  20. s Copyright © 2018 HashiCorp !23 Challenges Using Terraform or

    not, managing infrastructure has both technical and operational complexities These complexities present challenges for you as you grow SEGUE:: Let’s look at our current challenges
  21. Copyright © 2018 HashiCorp Scaling with Terraform !24 Manual Stage

    - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing Technological complexities (RED) Reproducibility - Can we duplicate this for testing, development? (RED) Change management - How are changes applied? How do you know what all needs change? (RED) Architecture - How did we do this in the first place? What do our apps require? Has anyone every simply forgot your application used a piece of infrastructure? Organizational complexities Auditing: Who did what, when? Consistency: things like naming conventions , but also practices Knowledge: How are things done here, what are the conventions, how do I find out? SEGUE: If I were to give each of these challenges a status
  22. Copyright © 2018 HashiCorp Scaling with Terraform !25 Manual Stage

    - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing I would mark them all as RED. None of these challenges are being met, or if they are, not in an ideal way Now, in theory you could setup your infrastructure perfectly, it never changes, and you’re done! In reality things change a lot, and discomfort in these areas is a sign of growth. SEGUE:: So That's the manual stage. It’s red
  23. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage 1: Manual ▪Stage 2: ▪Stage 3: ▪Stage 4: ▪Stage Next !26 The Journey from Startup to Enterprise SEGUE:: It's fine for starting out
  24. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage 1: Manual ▪Stage 2: ▪Stage 3: ▪Stage 4: ▪Stage Next !27 The Journey from Startup to Enterprise I imagine everyone here knows it's not ideal. SEGUE:: So let’s grow, let’s adopt Terraform and enter…
  25. Copyright © 2018 HashiCorp Scaling with Terraform !29 Semi-automated Stage

    ▪Adopting Infrastructure as Code ▪Machine images ▪Web Consoles Infrastructure as code: - Process of managing and provisioning infrastructure through machine-readable definition files Machine images - Investigating / starting immutable infrastructure - Docker, Lambda functions, Disk Images, all the things Packer makes SEGUE: Most importantly at this stage we...
  26. Copyright © 2018 HashiCorp Scaling with Terraform !30 Semi-automated Stage

    ▪Adopting Infrastructure as Code ▪Machine images ▪Web Consoles ▪Introduce Terraform! •Configuration! •Automation! •iteration! Introduce Terraform! You can tell this is all very exciting because of the exclamation points
  27. Copyright © 2018 HashiCorp Scaling with Terraform !31 Semi-automated Stage

    ▪Modeling Infrastructure with Configuration ▪Automation: Plan, Apply, Iterate At this stage, the 2 main features of Terraform we’re using are infrastructure as code to declaring how infrastructure should be And once we’ve declared it, we’re automating the creation and modification in a consistent, safe, and reproducible way
  28. Copyright © 2018 HashiCorp Scaling with Terraform !32 Semi-automated Stage

    - Modeling Infrastructure with Configuration To model, we use HCL, a Human friendly and powerful language Declare **Resources** and **properties**
  29. Copyright © 2018 HashiCorp Scaling with Terraform !33 Semi-automated Stage

    - Modeling Infrastructure with Configuration We use powerful language constructs, the simple example of COUNT here, to add power and flexibility to our descriptive language We establish relationships with **Interpolation** SEGUE: all this is read and interpreted by Terraform and used to make a graph
  30. Copyright © 2018 HashiCorp Scaling with Terraform !34 Semi-automated Stage

    - Modeling Infrastructure with Configuration DAG, I’m not going to go much more into detail because the graph itself isn’t the point. The point is we’re declaring our infrastructure, and Terraform reasons about how to make it SEGUE: Using this graph, knowing what’s our current state is, we can then make automation plans
  31. Copyright © 2018 HashiCorp Scaling with Terraform !36 Semi-automated Stage

    - Automation: Plan, Apply, Iterate Safely applying just those changes. Creating infrastructure in an automated manner. These are things we didn’t have in the manual stage, or simply couldn’t do responsibly SEGUE: So now we’re designing our infrastructure and automating it’s creation
  32. Copyright © 2018 HashiCorp Scaling with Terraform !38 Manual Stage

    - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing
  33. Copyright © 2018 HashiCorp Scaling with Terraform !39 Semi-automated Stage

    - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing We’ve upgraded our status! Technical complexities: (ORANGE) Reproducibility: config file, plan files (ORANGE) Change management: Automated, consistent workflow across Providers Organizational complexities: (ORANGE) Consistency: IaC using variables, interpolation (ORANGE) Knowledge sharing: configuration stored on file, applied consistently SEGUE:: Things are much better at this stage. We’ve improved a lot, but what are the next challenges?
  34. Copyright © 2018 HashiCorp Scaling with Terraform !40 Semi-automated Stage

    - New Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing State Management Operations As Armon said, there’s no free lunch, the semi-automated stage introduces some new things Tech: - Where is "our" state file Org: - External things may remain - Who’s running this thing? When?
  35. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage 1: Manual ▪Stage 2: Semi-automated Stage ▪Stage 3: ▪Stage 4: ▪Stage Next !41 The Journey from Startup to Enterprise So that’s the Semi Automated Stage. We’re automating and managing change consistently
  36. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage 1: Manual ▪Stage 2: Semi-automated Stage ▪Stage 3: ▪Stage 4: ▪Stage Next !42 The Journey from Startup to Enterprise SEGUE:: We’re still scaling up, so let’s look at the next stage and those new challenges
  37. Copyright © 2018 HashiCorp Scaling with Terraform !44 Infrastructure as

    Code Stage ▪ Organizational adoption ▪ Multiple Environments ▪ Collaboration ▪ Version Control Organizational: - Diminishing Web consoles usage, scripts, CLI, or other external processes Environments: - Near perfect reproduction of environments Collaboration: - multiple people now contributing to the infrastructure Version Control: - recording state in version control
  38. Copyright © 2018 HashiCorp Scaling with Terraform !45 Infrastructure as

    Code Stage ▪ Modules ▪ Workspaces ▪ Managed state With Terraform at this stage we start seeing
  39. Copyright © 2018 HashiCorp Scaling with Terraform !46 Infrastructure as

    Code Stage - Modules ▪Packaged Components ▪Inputs and Outputs • Self-contained Terraform configurations packaged as a group (VPC setup et.al) • Inputs and outputs like a regular Terraform Resource • Shareable: local file, VCS, S3 SEGUE:: Easy to write
  40. Copyright © 2018 HashiCorp Scaling with Terraform !47 Infrastructure as

    Code Stage - Modules $ tree ex-mod/ . ├── README.md ├── main.tf ├── variables.tf ├── outputs.tf Easy structure
  41. Copyright © 2018 HashiCorp Scaling with Terraform !48 Infrastructure as

    Code Stage - Modules # main.tf module “ex-mod" { source = “github.com/example/..“ version = "0.3.5" } output “mod-version” { value = “${module.ex-mod.address}” } In/Out: use as another resource with interpolation Common architectures are now reproducible, standardized, and consistent SEGUE:: on to workspaces
  42. Copyright © 2018 HashiCorp Scaling with Terraform !49 Infrastructure as

    Code Stage - Workspaces ▪Configuration + Environment ▪Same configuration, separate state files Workspaces in Terraform are defined as configuration + environment (dev, staging, production) - workspace is a CLI command managing multiple ~identical environments - Different local/remote state file - SEGUE::Can use in configurations
  43. Copyright © 2018 HashiCorp Scaling with Terraform !50 Infrastructure as

    Code Stage - Workspaces Use the example from before, count = 3
  44. Copyright © 2018 HashiCorp Scaling with Terraform !51 Infrastructure as

    Code Stage - Workspaces allow easy feature branch development style Tight coupling of state and config SEGUE:: the last bit we’re introducing here Managed State
  45. Copyright © 2018 HashiCorp Scaling with Terraform !52 Infrastructure as

    Code Stage - Managed State ▪Version control ▪Remote state At this stage we’re managing our generated state files. Version control systems to track the changes to state. Terraform records state is JSON format State file becomes like any other file in VCS: auditing possible SEGUE:: the other option is remote state
  46. Copyright © 2018 HashiCorp Scaling with Terraform !53 Infrastructure as

    Code Stage - Workspaces With Remote State, terraform CLI command behave as normal, but communicate with a remote store for all operations. Can be versioned - Terraform Enterprise - Consul - AzureRM Storage - Google Cloud Storage - S3 SEGUE:: We’ve leveled up on our Terraform usage
  47. Copyright © 2018 HashiCorp Scaling with Terraform !55 Semi-automated Stage

    - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing State Management Operations This is where we left off SEGUE:: After moving to the Infrastructure as Code stage, we’ve upgraded our status
  48. Copyright © 2018 HashiCorp Scaling with Terraform !56 Infrastructure as

    Code Stage - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing State Management Operations Technical complexities: (GREEN) Reproducibility: Modules / Workspaces (GREEN) Change management: Workspaces / Modules (ORANGE) Architecture: designing things, vetting them in environments (ORANGE) State management: VCS/Remote Organizational complexities: (ORANGE) Auditing: VCS, Assembly required (GREEN) Consistency: consistent environments with modules and workspaces (GREEN) Knowledge sharing: configs in VCS, modules, self documenting (ORANGE) Operations: Managing more env with same tools, safer
  49. Copyright © 2018 HashiCorp Scaling with Terraform !57 Infrastructure as

    Code Stage - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing State Management Operations I asked Armon again and he said there’s still no free lunch
  50. Copyright © 2018 HashiCorp Scaling with Terraform !58 Infrastructure as

    Code Stage - New Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing State Management Operations Operations Governance Secrets As we grow and continue to adopt IaC, some new issues will pop up (NEW)(RED) Operations - Where is this thing running? Who's running this thing? Bottleneck (NEW)(RED) Secrets - Organizational complexities: (NEW)(RED) Governance: Policies and Permissions As we scale, these new issues arise
  51. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage 1: Manual ▪Stage 2: Semi-automated Stage ▪Stage 3: Infrastructure as Code Stage ▪Stage 4: ▪Stage Next !59 The Journey from Startup to Enterprise That’s the Infrastructure as Code Stage
  52. Copyright © 2018 HashiCorp Scaling with Terraform ▪Intro ▪What is

    Terraform ▪4 Stages of Adoption ▪Stage 1: Manual ▪Stage 2: Semi-automated Stage ▪Stage 3: Infrastructure as Code Stage ▪Stage 4: ▪Stage Next !60 The Journey from Startup to Enterprise SEGUE:: Now we move on to our “final” stage
  53. s Copyright © 2018 HashiCorp !61 Collaborative Infrastructure as Code

    Stage The Collaborative Infrastructure as Code Stage It’s like the Infrastructure as Code stage, but it’s Collaborative. Says so right there ^
  54. Copyright © 2018 HashiCorp Scaling with Terraform !62 Collaborative Infrastructure

    as Code Stage ▪ Centralized ▪ Governance ▪ Enablement At this stage we need a centralized place to apply changes We’ll need governance to approve who can make changes, and where Enable development teams to self-serve and remove the bottle neck on the operations team
  55. Copyright © 2018 HashiCorp Scaling with Terraform !63 Collaborative Infrastructure

    as Code Stage ▪ Coordination ▪ Workspaces++ ▪ Registries Here we see a shift in how Terraform is used. In the past stages we were using the command line for our automation. At this stage, it becomes necessary to coordinate our automation SEGUE:: At this stage…
  56. Copyright © 2018 HashiCorp Scaling with Terraform !64 Collaborative Infrastructure

    as Code Stage - Coordination We need something Terraform Enterprise.
  57. Copyright © 2018 HashiCorp Scaling with Terraform !65 Collaborative Infrastructure

    as Code Stage - Coordination NOT A SALES PITCH NOT A SALES PITCH Terraform Enterprise is the result of working with practitioners and clients that reach this stage. Coordination, governance, enablement, that’s Terraform Enterprise. I’m sure you can bring and use other tools to this Stage, but this is the stage where Terraform Enterprise *lives*, that’s what it *does* My examples use TFE because it excels at these things
  58. Copyright © 2018 HashiCorp Scaling with Terraform !66 Collaborative Infrastructure

    as Code Stage - Coordination ▪ VCS Integration ▪ Team based permissions ▪ Terraform runs For coordination, Terraform Enterprise offers ^ Where before we automated creation and modification, we’re now automating the automator SEGUE:: With Terraform Enterprise, you get upgraded workspaces
  59. Copyright © 2018 HashiCorp Scaling with Terraform !67 Collaborative Infrastructure

    as Code Stage - Workspaces* Workspaces: (dev, staging, production) • Still represent configuration * environment • Separate remote states • Available as data sources for other teams to consume SEGUE:: You can inspect each workspace individually
  60. Copyright © 2018 HashiCorp Scaling with Terraform !68 Collaborative Infrastructure

    as Code Stage - Workspaces* Each has it’s own run history • can manually trigger, approve, discard
  61. Copyright © 2018 HashiCorp Scaling with Terraform !69 Collaborative Infrastructure

    as Code Stage - Workspaces* ▪ Independent variables per workspace ▪ Team based permissions ▪ State / Run history • ^^^^ • Variable are encrypted with Vault - this is now where credentials go • Team permissions are by organization and workspace, READ/WRITE/ADMIN • Log of state changes and their sources Still not an upsell or sales pitch, but at large scale of adoption, these features are practically required SEGUE:: now we go to the registry
  62. Copyright © 2018 HashiCorp Scaling with Terraform !70 Collaborative Infrastructure

    as Code Stage - Registry Yes, another external HashiCorp product enters the mix - again this is about automating the automator, not up-selling
  63. Copyright © 2018 HashiCorp Scaling with Terraform !71 Collaborative Infrastructure

    as Code Stage - Registry ▪ Modules from Vendor / experts ▪ Search, discover ▪ Open Source, public repos ▪ Published API protocol Terraform Registry enables self-service • Collection of published modules maintained by Vendors • Teams can easily search / discover the components they need • All are free and open source A limitation here is private modules. SEGUE:: You can implement your own with the API protocol. Or….
  64. Copyright © 2018 HashiCorp Scaling with Terraform !72 Collaborative Infrastructure

    as Code Stage - Registry You can simply use the private registry built in to Terraform Enterprise
  65. Copyright © 2018 HashiCorp Scaling with Terraform !73 Collaborative Infrastructure

    as Code Stage - Coordination STILL NOT A SALES PITCH Still not a sales pitch. Says so right there ^ Builtin private registry is just the best example SEGUE:: Now that I’m done *NOT* sales pitching
  66. Copyright © 2018 HashiCorp Scaling with Terraform !75 Infrastructure as

    Code Stage - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing State Management Operations Operations Governance Secrets
  67. Copyright © 2018 HashiCorp Scaling with Terraform !76 Collaborative Infrastructure

    as Code Stage - Challenges Technical Operational Reproducibility Auditing Change Management Consistency Architecture Knowledge Sharing State Management Operations Operations Governance Secrets Of course everything is green now! What kind of talk would end without green everything • Centralized System with coordination and team/workspace permissions • Consistent and safe iteration and management of infrastructure • Modules and registry offer Self-Service to teams • Encrypted Secrets backed by Vault • Audit: run logs, pull request history, state history • Team based permissions
  68. Copyright © 2018 HashiCorp Scaling with Terraform 78 Stage next

    ▪ New, Improved plugin interfaces ▪ HCL 2 ▪ Continued Providers growth and enablement Terraform Open Source ▪ Sentinel: Policy as Code ▪ Enhanced Remote Backends ▪ Configuration Designer* ▪ Promotions Workflow* Terraform Enterprise *coming soon…
  69. s Copyright © 2018 HashiCorp The End !79 Thank you!

    - Clint Thats the end. Says so right there ^