How to validate policies within a directory? #8548
-
I have a lot of policies contained in a folder called It is tedious to try validating those one-by one Is there any command that lets me validate policies just by specifying the directory path? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Not sure about custodian option but you can loop it with |
Beta Was this translation helpful? Give feedback.
-
Yeah @benipeled 's answer is a good one. You can also use something like xargs in helpful ways. To validate all YAML files in a given policy directory for instance: find /path/to/my/policies -iname "*.y*ml" | xargs custodian validate Or maybe if you're in a git repository of policies and want to validate only policies that differ from what's on git diff --name-only main.. | xargs custodian validate That said, thanks for asking this question! I occasionally still use this simpler command: custodian validate /path/to/my/policies/*.y*ml Which works fine if all of your policies are valid, but it can report errors multiple times in a way that is misleading. But that feels like a bug we should fix, so... #8565 |
Beta Was this translation helpful? Give feedback.
Yeah @benipeled 's answer is a good one. You can also use something like xargs in helpful ways. To validate all YAML files in a given policy directory for instance:
find /path/to/my/policies -iname "*.y*ml" | xargs custodian validate
Or maybe if you're in a git repository of policies and want to validate only policies that differ from what's on
main
:git diff --name-only main.. | xargs custodian validate
That said, thanks for asking this question! I occasionally still use this simpler command:
custodian validate /path/to/my/policies/*.y*ml
Which works fine if all of your policies are valid, but it can report errors multiple times in a way that is misleading. But that feels like a bug we s…