-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.ts
More file actions
92 lines (86 loc) · 2.31 KB
/
init.ts
File metadata and controls
92 lines (86 loc) · 2.31 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { Argv } from 'yargs';
import { monitoring, aws } from '../../lib';
import { setVerbose } from '../../lib/logger';
export const command = 'init [options]';
export const desc = 'Setup monitoring stack';
export const builder = (yargs: Argv<{}>): Argv<{}> => {
return yargs.options({
p: {
alias: 'profile',
describe: 'AWS IAM Profile',
type: 'string',
},
r: {
alias: 'region',
describe: 'Target region',
type: 'string',
},
o: {
alias: 'output',
describe: 'Folder to setup monitoring',
type: 'string',
},
i: {
alias: 'include',
describe: 'List of included names',
type: 'array',
default: [],
},
e: {
alias: 'exclude',
describe: 'List of excluded names',
type: 'array',
default: [],
},
s: {
alias: 'service',
describe: 'List of services. Write without quotes with space - example -s lambda rds eks',
type: 'array',
choices: ['lambda', 'dynamodb', 'ecs', 'apigateway', 'cloudfront', 'rds', 'eks', 'loggroup', 'appsync', 'sqs'],
default: ['lambda', 'dynamodb', 'ecs', 'apigateway', 'cloudfront', 'rds', 'eks', 'loggroup', 'appsync', 'sqs'],
},
d: {
alias: 'dry',
default: false,
type: 'boolean',
},
t: {
alias: 'stage',
describe: 'Stage of the deployment',
type: 'string',
default: 'dev',
},
ep: {
alias: 'endpoints',
default: [],
describe:
'Add endpoints directly or AWS SSM params name to retrieve endpoints from SSM, e.g. ssm:my-endpoint-${stage}, stage is always added to the end',
type: 'array',
},
v: {
alias: 'verbose',
describe: 'Set verbose logging',
type: 'boolean',
default: false,
},
interactive: {
default: false,
type: 'boolean',
},
sso: {
default: false,
describe: 'Use an AWS profile with SSO credentials',
type: 'boolean',
},
});
};
export const handler = async (args: monitoring.Args): Promise<void> => {
setVerbose(args.verbose);
await aws.setAWSCredentials(args.profile, args.region, args.sso);
const awsConfig = await monitoring.getAllFromAWS(args);
if (args.dry) {
monitoring.logAWS(awsConfig);
return;
}
await monitoring.generateMonitoring(awsConfig, args);
};