@@ -57,6 +57,10 @@ def _master_account_type(val: str, pattern: str = r'[0-9]{12}'):
57
57
parser .add_argument ('--enabled_regions' , type = str ,
58
58
help = ('Regions to enable Detective. If not specified, '
59
59
'all available regions enabled.' ))
60
+ parser .add_argument ('--disable_email' , action = 'store_true' ,
61
+ help = ('Don\' t send emails to the member accounts. Member '
62
+ 'accounts must still accept the invitation before '
63
+ 'they are added to the behavior graph.' ))
60
64
return parser .parse_args (args )
61
65
62
66
@@ -228,7 +232,7 @@ def _master_memberList(g: str) -> typing.List[typing.Dict]:
228
232
{g : {x ['AccountId' ] for x in v if x ['Status' ] == 'INVITED' } for g , v in pending })
229
233
230
234
231
- def create_members (d_client : botocore .client .BaseClient , graph_arn : str , account_ids : typing .Set [str ],
235
+ def create_members (d_client : botocore .client .BaseClient , graph_arn : str , disable_email : bool , account_ids : typing .Set [str ],
232
236
account_csv : typing .Dict [str , str ]) -> typing .Set [str ]:
233
237
"""
234
238
Creates member accounts for all accounts in the csv that are not present in the graph member set.
@@ -257,7 +261,8 @@ def create_members(d_client: botocore.client.BaseClient, graph_arn: str, account
257
261
for x in set_difference ]
258
262
response = d_client .create_members (GraphArn = graph_arn ,
259
263
Message = 'Automatically generated invitation' ,
260
- Accounts = new_members )
264
+ Accounts = new_members ,
265
+ DisableEmailNotification = disable_email )
261
266
for error in response ['UnprocessedAccounts' ]:
262
267
logging .exception (f'Could not create member for account { error ["AccountId" ]} in '
263
268
f'graph { graph_arn } : { error ["Reason" ]} ' )
@@ -336,7 +341,7 @@ def enable_detective(d_client: botocore.client.BaseClient, region: str):
336
341
337
342
for graph , members in all_members .items ():
338
343
new_accounts = create_members (
339
- d_client , graph , members , aws_account_dict )
344
+ d_client , graph , args . disable_email , members , aws_account_dict )
340
345
print ("Sleeping for 5s to allow new members' invitations to propagate." )
341
346
time .sleep (5 )
342
347
accept_invitations (args .assume_role , itertools .chain (
0 commit comments