Terraform
Importers
terraformer
# https://github.com/GoogleCloudPlatform/terraformer/blob/master/docs/aws.md
terraformer import aws --resources=api_gateway --connect=true --regions=ap-southeast-1
terraform state replace-provider -auto-approve registry.terraform.io/-/aws hashicorp/aws
Tools
- driftctl - Detect, track and alert on infrastructure drift.
- terragrunt - Terragrunt is a thin wrapper that provides extra tools for keeping your configurations DRY, working with multiple Terraform modules, and managing remote state.
- tfrefactor - Automated refactoring for Terraform.
- tfadd - Generate valid Terraform configuration from state.
Linters
- tflint - A Pluggable Terraform Linter.
- tfsec - A static analysis security scanner for your Terraform code.
Recipes
Migrate Terraform remote tfstates
terraform state pull > dev.tfstate
terraform state mv -state-out=dev.tfstate module.lambda.module.your_function module.your_function
terraform state mv \
-state=dev.tfstate \
-state-out=workspace/dev.tfstate \
aws_iam_role.a \
aws_iam_role.a
terraform state push dev.tfstate
Resources
- How Terraform Works: A Visual Intro
- My Terraform Development Workflow
- My Terraform Standards
- Terraform Best Practices
- Terraform Opinion #23: Use list of objects over map of maps
AWS
Examples
- GOV.UK Infrastructure
- partinfra-terraform - Terraform configuration for Participation Infrastructure.