Refactoring Infrastructure as Code

#5 - Infrastructure as Code - Kief Morris

Topic 9 of 17

Published Sep 7, 2020 · Clip 30:53–36:18 (5:25)

Kief addresses refactoring infrastructure code, a hard topic he is adding to the second edition of his book. He suggests techniques from software like blue-green deployments, dark launches, canary releases, and feature flags, and building new infrastructure instances before switching over. For Terraform state changes, he recommends the Expand and Contract pattern from database schema changes: add new subnets alongside old ones, move servers over piece by one, then delete the old subnets. He warns against hand-editing state files ('infrastructure surgery') and suggests scripting such state edits with testing between environments.