@@ -64,6 +64,10 @@ def __call__(self, parser, namespace, values, option_string=None):
64
64
parser .add_argument ('--enabled_regions' , type = str ,
65
65
help = ('Regions to enable Detective. If not specified, '
66
66
'all available regions enabled.' ))
67
+ parser .add_argument ('--disable_email' , action = 'store_true' ,
68
+ help = ('Don\' t send emails to the member accounts. Member '
69
+ 'accounts must still accept the invitation before '
70
+ 'they are added to the behavior graph.' ))
67
71
parser .add_argument ('--tags' ,
68
72
action = ParseCommaSeparatedKeyValuePairsAction ,
69
73
help = 'Comma-separated list of tag key-value pairs to be added '
@@ -240,7 +244,7 @@ def _master_memberList(g: str) -> typing.List[typing.Dict]:
240
244
{g : {x ['AccountId' ] for x in v if x ['Status' ] == 'INVITED' } for g , v in pending })
241
245
242
246
243
- def create_members (d_client : botocore .client .BaseClient , graph_arn : str , account_ids : typing .Set [str ],
247
+ def create_members (d_client : botocore .client .BaseClient , graph_arn : str , disable_email : bool , account_ids : typing .Set [str ],
244
248
account_csv : typing .Dict [str , str ]) -> typing .Set [str ]:
245
249
"""
246
250
Creates member accounts for all accounts in the csv that are not present in the graph member set.
@@ -269,7 +273,8 @@ def create_members(d_client: botocore.client.BaseClient, graph_arn: str, account
269
273
for x in set_difference ]
270
274
response = d_client .create_members (GraphArn = graph_arn ,
271
275
Message = 'Automatically generated invitation' ,
272
- Accounts = new_members )
276
+ Accounts = new_members ,
277
+ DisableEmailNotification = disable_email )
273
278
for error in response ['UnprocessedAccounts' ]:
274
279
logging .exception (f'Could not create member for account { error ["AccountId" ]} in '
275
280
f'graph { graph_arn } : { error ["Reason" ]} ' )
@@ -348,7 +353,7 @@ def enable_detective(d_client: botocore.client.BaseClient, region: str, tags: di
348
353
349
354
for graph , members in all_members .items ():
350
355
new_accounts = create_members (
351
- d_client , graph , members , aws_account_dict )
356
+ d_client , graph , args . disable_email , members , aws_account_dict )
352
357
print ("Sleeping for 5s to allow new members' invitations to propagate." )
353
358
time .sleep (5 )
354
359
accept_invitations (args .assume_role , itertools .chain (
0 commit comments