-
Notifications
You must be signed in to change notification settings - Fork 16
/
run_terminate_ses.py
executable file
·62 lines (47 loc) · 1.73 KB
/
run_terminate_ses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
from env import env
from run_common import AWSCli
from run_common import print_session
aws_cli = AWSCli('us-east-1')
ses = env['ses']
def terminate_config_set():
for cs in ses['CONFIGURATION_SETS']:
name = cs['NAME']
cmd = ['ses', 'delete-configuration-set',
'--configuration-set-name', name]
aws_cli.run(cmd, ignore_error=True)
def terminate_email_identity():
for ii in ses['IDENTITIES']:
email = ii['EMAIL']
cmd = ['ses', 'delete-identity',
'--identity', email]
aws_cli.run(cmd, ignore_error=True)
def terminate_domain_identity():
for ii in ses['DOMAIN_IDENTITIES']:
cmd = ['ses', 'delete-identity',
'--identity', ii['DOMAIN']]
aws_cli.run(cmd, ignore_error=True)
def terminate_receipt_rule_set():
cmd = ['ses', 'set-active-receipt-rule-set']
aws_cli.run(cmd)
for ii in ses['DOMAIN_IDENTITIES']:
cmd = ['ses', 'delete-receipt-rule-set',
'--rule-set-name', ii['RULE_SET_NAME']]
aws_cli.run(cmd, ignore_error=True)
for rr in ii['RULES']:
cmd = ['s3', 'rm', 's3://%s/%s' % (rr['BUCKET_NAME'], env['common']['PHASE']), '--recursive']
aws_cli.run(cmd, ignore_error=True)
if __name__ == "__main__":
from run_common import parse_args
parse_args()
################################################################################
#
# start
#
################################################################################
print_session('terminate ses')
################################################################################
terminate_config_set()
terminate_email_identity()
terminate_domain_identity()
terminate_receipt_rule_set()