Created
July 15, 2024 14:31
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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