This is a presentation for open source practitioners who want to upgrade Terraform. It compiles useful information and patterns for reference. The example is for AWS infrastructure but can be used to practice upgrade patterns.
Downside: Import each component. Mitigation: Only choose specific components. Big Bang Upgrade and see what happens. Downside: Likely to break production. Mitigation: Use isolated environment. Strangler Pattern Refactor to reduce complexity and upgrade. Downside: Decoupling can be difficult. Mitigation: N/A !9
DNS, and more. Microlith E.g., Application + SQS. Changes to SQS reflect in application. Dependency Graph Micro-ish E.g., EKS Cluster separate from Kubernetes deployment. !11
for human users ▪ Infrastructure in development environments ▪ Repositories without: – Complex templating or functions – Cross-account dependencies !13
upgrade guide and CHANGELOG. 3. Fix configuration for upgrade gotchas. 4. Apply current version to assure state. 5. Plan and apply new version.* * In pipeline, set toggle for version. !20
Terraform doesn't allow running any operations against a state that was written by a future Terraform version. The state is reporting it is written by Terraform '0.8.8'. Please run at least that version of Terraform to continue !21
rm <module.name.resource.id> -backup=<date>.tfstate # Comment out from code or set count = 0 > vim <file>.tf # Run to ensure no other changes are applied > terraform-0.1 plan > terraform-0.1 apply !25
are applied > terraform-0.2 plan > terraform-0.2 apply # Using backup state file, find ID of excluded resource. > jq -r -c '.modules[].resources."<resource.id>".primary.id' <date>.tfstate tf-################### # Uncomment code or remove count and re-initialize # Add back to state terraform-0.2 import <module.name.resource.id> tf- ################### !26
one module to another > terraform-0.2 state mv <module.name.resource.id> <module2.name.resource.id2> # Run to ensure state doesn’t change terraform-0.2 apply !27
0.7 to 0.10. – git checkout, backend, provider ▪ Refactor SNS to use count. – terraform state mv ▪ Upgrade networking from 0.7 to 0.10. ▪ Destroy. – terraform plan -target !29