Skip to content

Instantly share code, notes, and snippets.

@kapilt
Created July 31, 2019 18:01
Show Gist options
  • Select an option

  • Save kapilt/f4638aa1f2b429f6133d4bb6156496ce to your computer and use it in GitHub Desktop.

Select an option

Save kapilt/f4638aa1f2b429f6133d4bb6156496ce to your computer and use it in GitHub Desktop.
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