Skip to main content

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

AWS

Examples