-
Notifications
You must be signed in to change notification settings - Fork 16
/
run_create_lambda.py
executable file
·68 lines (55 loc) · 2.1 KB
/
run_create_lambda.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
63
64
65
66
67
68
#!/usr/bin/env python3.12
from env import env
from run_common import print_session
from run_common import remove_kaji_in_template_dir
from run_create_lambda_cron import run_create_lambda_cron
from run_create_lambda_default import run_create_lambda_default
from run_create_lambda_event import run_create_lambda_event
from run_create_lambda_ses_sqs import run_create_lambda_ses_sqs
from run_create_lambda_sns import run_create_lambda_sns
from run_create_lambda_sqs import run_create_lambda_sqs
options, args = dict(), list()
if __name__ == "__main__":
from run_common import parse_args
options, args = parse_args()
################################################################################
#
# start
#
################################################################################
print_session('create lambda')
remove_kaji_in_template_dir()
target_name = None
region = options.get('region')
is_target_exists = False
if len(args) > 1:
target_name = args[1]
for settings in env.get('lambda', list()):
if target_name and settings['NAME'] != target_name:
continue
if region and settings['AWS_REGION'] != region:
continue
is_target_exists = True
if settings['TYPE'] == 'default':
run_create_lambda_default(settings['NAME'], settings, options)
elif settings['TYPE'] == 'cron':
run_create_lambda_cron(settings['NAME'], settings, options)
elif settings['TYPE'] == 'sns':
run_create_lambda_sns(settings['NAME'], settings, options)
elif settings['TYPE'] == 'sqs':
run_create_lambda_sqs(settings['NAME'], settings, options)
elif settings['TYPE'] == 'ses_sqs':
run_create_lambda_ses_sqs(settings['NAME'], settings, options)
elif settings['TYPE'] == 'event':
run_create_lambda_event(settings['NAME'], settings, options)
else:
print(f'{settings["TYPE"]} is not supported')
raise Exception()
if is_target_exists is False:
mm = list()
if target_name:
mm.append(target_name)
if region:
mm.append(region)
mm = ' in '.join(mm)
print(f'lambda: {mm} is not found in config.json')