Created
November 5, 2025 15:10
-
-
Save duboisf/3676b2ac80e4c03790f35fcea42e9774 to your computer and use it in GitHub Desktop.
Sort aws iam policy document by sid, and sort action and resource arrays
This file contains hidden or 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
| #!/bin/sh | |
| jq ' | |
| .Statement |= sort_by(.Sid) | | |
| .Statement |= map( | |
| if .Action then .Action |= (if type == "array" then sort else . end) else . end | | |
| if .Resource then .Resource |= (if type == "array" then sort else . end) else . end | |
| ) | |
| ' \ | |
| | jq --sort-keys . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment