Writing
See the examples under https://github.com/salesforce/policy_sentry/tree/master/examples/library-usage/writing.
command.write_policy
Given a Policy Sentry YML template, write a least-privilege IAM Policy in CRUD mode or Actions mode.
RegisterLengthOption
Mark this option as getting a _length option
RegisterLengthOptionHelp
Translate help for the hidden _length suffix
RegisterMinimizeLengthCommand
Translate any opt= to opt_length= as needed
parse_args(self, ctx, args)
Given a context and a list of arguments this creates the parser
and parses the arguments, then modifies the context as necessary.
This is automatically invoked by :meth:make_context
.
Source code in policy_sentry/command/write_policy.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
write_policy_with_template(cfg, minimize=None)
This function is called by write-policy so the config can be passed in as a dict without running into a Click-related error. Use this function, rather than the write-policy function, if you are using Policy Sentry as a python library.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cfg |
|
The loaded YAML as a dict. Must follow Policy Sentry dictated format. |
required |
minimize |
|
Minimize the resulting statement with safe usage of wildcards to reduce policy length. Set this to the character length you want - for example, 0, or 4. Defaults to none. |
None |
Returns:
Type | Description |
---|---|
Dictionary |
The JSON policy |
Source code in policy_sentry/command/write_policy.py
119 120 121 122 123 124 125 126 127 128 129 130 131 |
|