Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
60 lines (47 sloc) 2.65 KB
export type AutowatchAction = "generateAlarms" | "addAlarmsFromFile" | "listSnsTopics" | "help" | "";
export class Config {
public readonly region : string;
public readonly notificationArn : string;
public readonly input : string;
public readonly output : string;
public readonly action : AutowatchAction;
public readonly help : boolean;
public readonly addImmediately : boolean;
public static getConfig() : Config {
const argvs = process.argv.slice(2);
if(argvs.length == 0){
return {help: true, addImmediately: false, action: "",
region: "", notificationArn: "", input: "", output: ""};
const argv = require("minimist")(argvs, {"boolean": ["help", "addImmediately"], "default": {"region": "us-east-1", "output": "alarms.json"}});
return <Config> argv;
public static outputHelp() : void {
const help = `
Usage cloudwatch-auto [options]
cloudwatch-auto automatically adds baseline alarms to your AWS resources.
These alarms are intended to serve only as a starting point, mostly useful when you're just starting out with AWS.
Note: The AWS client authenticates automatically using IAM roles, environment variables, or a JSON credential file.
One of these must be available in order for cloudwatch-auto to work.
Action Flags:
Pass any one of these as an argument to --action. Ex. --action=generateAlarms
generateAlarms: Generates a file based on AWS resources. The file is alarms.json by default.
addAlarmsFromFile: Add alarms from a JSON file specified by --input (see below)
listSnsTopics: Lists the available SNS topics
help: Prints this message
--notificationArn The SNS topic ARN to use for notifications. Use with 'generateAlarms'
--output The JSON file to output alarms to. Use with 'generateAlarms'
--addImmediately Set if you want to just add alarms immediately. Use with 'generateAlarms'
--input The JSON file to add alarms from. Use with 'addAlarmsFromFile'
--region The AWS region to access. Defaults to us-east-1
# This will create a file named alarms.json
cloudwatch-auto --action=generateAlarms --notificationArn=arn:aws:sns:us-east-1:123:ContactAndCloudWatch
# Now, create the alarms contained inside alarms.json. You can edit the alarms before adding them.
cloudwatch-auto --action=addAlarmsFromFile --input=alarms.json