Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tsprlng/216e9e7c0016644b110d2005005aacef to your computer and use it in GitHub Desktop.
Save tsprlng/216e9e7c0016644b110d2005005aacef to your computer and use it in GitHub Desktop.
Migrate a deprecated terraform property, by applying a JQ script directly to the state file
#!/usr/bin/env jq
# Apply to a Terraform state file, to replace the deprecated alb_target_group_arn attribute with lb_target_group_arn on each aws_autoscaling_attachment resource.
(
(.resources | .[] | select(.mode=="managed") | select(.type=="aws_autoscaling_attachment")).instances
| .[]
) |= (
.attributes |= (
(.lb_target_group_arn = .alb_target_group_arn)
| del(.alb_target_group_arn)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment