Created
July 31, 2019 18:01
-
-
Save kapilt/f4638aa1f2b429f6133d4bb6156496ce to your computer and use it in GitHub Desktop.
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
| import sys | |
| import json | |
| from c7n.config import Config | |
| from c7n.resources import load_resources | |
| from c7n.policy import load | |
| def main(): | |
| if not len(sys.argv) == 3: | |
| print('usage policy.yml permissions.json') | |
| return | |
| ifile = sys.argv[1] | |
| ofile = sys.argv[2] | |
| load_resources() | |
| policies = load(Config.empty(), ifile) | |
| policy_perms = {} | |
| for p in policies: | |
| perms = p.get_permissions() | |
| perms = list(perms) | |
| perms.sort() | |
| policy_perms[p.name] = list(perms) | |
| with open(ofile, 'w') as f: | |
| f.write(json.dumps(policy_perms, indent=2)) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment