tfsort

Sort Terraform variables, outputs, and blocks in consistent order.

brewmacoslinux
Try with needOr install directly
Source

About

CLI to sort Terraform variables and outputs

Commands

tfsort

Examples

sort all variables in a terraform file$ tfsort main.tf
sort terraform file and write changes back$ tfsort -w main.tf
sort all terraform files in current directory$ tfsort *.tf
check if terraform file is sorted without modifying it$ tfsort main.tf > /dev/null && echo 'sorted'
sort entire terraform directory recursively$ tfsort -w .