cmd
IAM Bindings CLI command definition.
ask_for_authgroup_config(repo_info, auth_group_name)
Ask the user for configuration used to generate IAM binding Terraform files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_info |
TeamRepoInfo
|
TeamRepoInfo object containing info about the team's IaC repo, in this function the team's repo path is used. |
required |
auth_group_name |
Optional[str]
|
Name of an auth group. If not specified, then the user is prompted explicitly for this. |
required |
Returns:
Type | Description |
---|---|
AuthGroupIAMConfig
|
User supplied config used to generate IAM Terraform files |
Raises:
Type | Description |
---|---|
MissingUserSuppliedInfoError
|
if the user failed to specify enough information (such as at least one environment) |
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
ask_for_config(repo_info, auth_group)
Ask the user for configuration used to generate the bindings. Supports multiple auth groups.
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
ask_for_rationale()
Ask the user for a reason for adding the IAM bindings.
This text is included in the commit message and serves as an audit log.
Returns:
Type | Description |
---|---|
Any
|
User-supplied rationale for adding the IAM bindings |
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
262 263 264 265 266 267 268 269 270 |
|
bail_out(message, exit_code=1)
Print an exit message and exit the command with a status code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to print when exiting. |
required |
exit_code |
int
|
Exit code to use when exiting. 0 means ok. |
1
|
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
273 274 275 276 277 278 279 280 281 |
|
cleanup_iac_temp_folder(iac_repo_clone_path)
Cleans up temporary files in the .config folder that were cloned from github.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iac_repo_clone_path |
str
|
Path to the cloned IaC repo (i.e the temporary files). |
required |
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
combine_configs(config)
Combine all configurations.
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
144 145 146 147 148 149 150 |
|
create_git_branch(repo_path, config, files, tree)
Push a new branch with the generated IAM bindings files to GitHub.
Create a git branch with a descriptive name and detailed commit message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_path |
str
|
path to a local clone of the IaC git repo |
required |
config |
IAMBindingConfig
|
user preferences |
required |
files |
List[TextIOWrapper]
|
the Terraform IAM binding files that should be applied through a new PR |
required |
tree |
str
|
plain-text version of the summary rich.Tree which is displayed after running iam-bindings |
required |
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
iam_bindings(auth_group=typer.Option(None, '--auth-group', '-g', help='Name of "auth group", such as demo-enhjoern-a-support'), push_to_github=typer.Option(True, '--github/--no-github', help='True if the changes should be be pushed as a branch to GitHub'), source_config_file=typer.Option(None, '--source-config', help='Read config from json instead of prompting interactively'), target_config_file=typer.Option(None, '--target-config', help='Name of target config json file (if you later want to replay without interactive prompting)'), team_name=typer.Option('', '--team-name', '-t', help='Name of the team you want to create bindings for (without -iac suffix)'))
Create IAM Binding Terraform files that assign roles and permissions to a group of Dapla users.
You are prompted to supply information such as name of the group, environments, project roles, bucket roles and also a timeframe that the IAM binding should be constrained by. Terraform files are then created, one for each environment and auth group, keeping configuration neatly grouped and separated.
Example:
Let's say you want the support group of a team (e.g. demo-enhjoern-a
) to be able to administer Secret Manager
for a limited amount of time in both staging
and prod
environments. The output from this command would then
be two files: iam-support-staging.tf
and iam-support-prod.tf
.
Note that the command is strictly working with one auth group. You need to run the command multiple times if you want to create IAM bindings for multiple groups. Alternatively, you can record the config and re-run in non-interactive mode, only changing the name of the auth group between executions.
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
52 53 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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
print_summary(config, target_tf_files)
Print a summary of the executed command, detailing the user's choices and the resulting files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
IAMBindingConfig
|
The user supplied configuration that was used. |
required |
target_tf_files |
List[TextIOWrapper]
|
The generated Terraform files. |
required |
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
summarise_env(env, team_name)
Generate the summary for one environment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env |
EnvironmentIAMConfig
|
The user supplied configuration for a specific environment. |
required |
team_name |
str
|
The team's name. |
required |
Source code in dapla_team_cli/tf/iam_bindings/cmd.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|