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
Bases: click.Option
Mark this option as getting a _length option
Source code in policy_sentry/command/write_policy.py
19 20 21 |
|
RegisterLengthOptionHelp
Bases: click.Option
Translate help for the hidden _length suffix
Source code in policy_sentry/command/write_policy.py
24 25 26 27 28 29 |
|
RegisterMinimizeLengthCommand
Bases: click.Command
Translate any opt= to opt_length= as needed
Source code in policy_sentry/command/write_policy.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
write_policy(input_file, minimize, minimize_length, fmt, verbose)
Write least-privilege IAM policies, restricting all actions to resource ARNs.
Source code in policy_sentry/command/write_policy.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
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:
Name | Type | Description |
---|---|---|
Dictionary | The JSON policy |
Source code in policy_sentry/command/write_policy.py
124 125 126 127 128 129 130 131 132 133 134 135 136 |
|