Inspect one resource in state

Show all attributes of one address to investigate drift or bugs

terraform state show 'module.vpc.aws_subnet.private[0]'

tool
terraform43 commands
tags
terraformdebugtroubleshooting

More terraform commands

  • terraform state list | grep -i 'aws_iam'

    Filter managed addresses to see what Terraform tracks before any state surgery

  • cat > import.tf <<'EOF' import { to = aws_instance.web id = "<id>" } EOF terraform plan -generate-config-out=generated.tf

    Declarative import; -generate-config-out writes the HCL for the imported object

  • cat >> moved.tf <<'EOF' moved { from = aws_instance.web to = aws_instance.app } EOF

    Rename addresses in code without destroy and recreate; the change stays in version control

  • terraform apply -replace='aws_instance.web'

    Force one resource to be destroyed and created again; replaces the deprecated terraform taint

  • terraform plan -target='module.db.aws_db_instance.main'

    Limit the plan to one address; -target is for emergencies and can hide drift

all 43 terraform commands