migrating healthcare gov to terraform lessons learned
play

Migrating HealthCare.gov to Terraform: Lessons Learned Christian - PowerPoint PPT Presentation

Migrating HealthCare.gov to Terraform: Lessons Learned Christian Monaghan @monaghan_a_gram Cofounder, Nava PBC What is Terraform? A tool for building , changing , and versioning infrastructure Manage cloud providers Infrastructure as Code


  1. Migrating HealthCare.gov to Terraform: Lessons Learned Christian Monaghan @monaghan_a_gram Cofounder, Nava PBC

  2. What is Terraform?

  3. A tool for building , changing , and versioning infrastructure

  4. Manage cloud providers

  5. Infrastructure as Code Declarative syntax ● Source control ● Variable support ●

  6. Execution plans Developer reviews ● plan before proceeding

  7. Resource graph Resources created in ● dependency order

  8. Resource graph Resources created in ● dependency order

  9. Our project history

  10. AWS Cloudformation JSON interface 3,000+ lines for 1 Virtual Private Cloud (VPC) Managing dozens of VPCs

  11. Custom tooling to interact with Cloudformation YAML Custom AWS Config script Cloudformation

  12. Challenges we faced with our existing tooling

  13. Maintaining custom code :( Complex ● Not unit tested ● Limited documentation, quickly out of date ● Increasing bloat ● Hard to understand ● Hard to debug ●

  14. Unable to incorporate manual changes Past examples: Horizontally scale NATs (Network Address Translation) ● Adding a temporary second Elastic Load Balancer ● Scaling down from 3 availability zones to 1 availability zone ● Swap in new Elastic IPs ●

  15. Uncertain client demands Must build atop partially provisioned ● vpc infrastructure Client frequently requesting custom ● architecture changes Client might make manual changes ● that would be unrecoverable in Cloudformation

  16. Proliferating use cases Load testing resources ● Continuous Integration clusters ● Custom monitoring ● Graphite/Graphana ● Nessus scanning clusters ●

  17. We were trying to shoehorn all these new use cases into our existing tooling

  18. Engineering goal

  19. Manage all infrastructure with a single tool that is flexible , extensible , fast , and well-supported

  20. Choosing the right tool

  21. Tools we considered

  22. Chef, Puppet, Ansible, SaltStack These are configuration management tools ● Install and manage software on existing machines ●

  23. Why we chose Terraform Incorporate manual changes ● Declarative syntax, easy to read, understand, extend ● Supports multiple providers ● Separates planning and execution ● Well-supported, open-source ● Modular ●

  24. Some Terraform basics

  25. How it knows what to provision Changes Desired state Actual state required

  26. Desired state looks like this

  27. Actual state looks like this

  28. Prototyping

  29. Greenfield approach State Define Diff Apply Updated

  30. Reverse engineering approach Import Define Diff Apply State

  31. Refactor to use variables Hardcoded Variables

  32. Testing 1. Successfully provision a new VPC 2. Application functional a. Passes health checks b. Passes smoke testing 3. Infrastructure security scan a. AWS Trusted Advisor

  33. End result A configuration file (.tf) that ● represents one complete vpc configuration A state file (.tfstate) that ● represents one existing vpc

  34. Design

  35. How can we design this for reuse? ... AppA Test AppB Test ... AppA Staging AppB Staging ... AppA Prod AppB Prod ... AppA ... AppB ...

  36. Existing design Variable inputs Assemble building blocks Building blocks

  37. Implementation

  38. Build new VPC's & cutover traffic

  39. Learnings

  40. Use shared modules sparingly

  41. Use shared modules sparingly Sharing modules within applications worked well

  42. Use shared modules sparingly Sharing modules across applications did not work well

  43. Use shared modules sparingly Change the Elastic Load Balancer module

  44. Use shared modules sparingly

  45. Use shared modules sparingly co��t���s

  46. Migrating infrastructure in place It's possible, but time consuming

  47. Importing existing state Native terraform import CLI utility ● Only imports one resource at a time ○ Requires manually finding each resource id relevant to a particular vpc ○ Third party open source terraforming CLI ● Imports all resources in a region ○ Cannot narrow scope to a specific vpc ○

  48. Lock resources to a particular terraform version

  49. Terraform needs to be managed in CI/CD Otherwise: Risk losing internet connection in mid-apply ● No record of who changed what when ● Developers bump versions unintentionally ●

  50. Semantically version modules with git tags Good Bad

  51. Terraform utilities

  52. terraforming Export existing AWS resources to Terraform

  53. tfenv Terraform version manager inspired by rbenv TODO: screenshot

  54. terraform fmt Before After

  55. terraform-docs Generate docs from terraform modules

  56. Thank you @monaghan_a_gram

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend