in src/watchful.ts [79:121]
constructor(scope: Construct, id: string, props: WatchfulProps = { }) {
super(scope, id);
this.alarmActions = [
...(props.alarmActionArns ?? []).map((alarmActionArn) => ({ bind: () => ({ alarmActionArn }) })),
...(props.alarmActions ?? []),
];
if ((props.alarmEmail || props.alarmSqs) && !props.alarmSns) {
this.alarmTopic = new sns.Topic(this, 'AlarmTopic', { displayName: 'Watchful Alarms' });
}
if (props.alarmSns) {
this.alarmTopic = props.alarmSns;
}
if (props.alarmEmail && this.alarmTopic) {
this.alarmTopic.addSubscription(
new sns_subscriptions.EmailSubscription(props.alarmEmail),
);
}
if (props.alarmSqs && this.alarmTopic) {
this.alarmTopic.addSubscription(
new sns_subscriptions.SqsSubscription(
// sqs.Queue.fromQueueArn(this, 'AlarmQueue', props.alarmSqs)
props.alarmSqs,
),
);
}
if (props.dashboard === false && props.dashboardName) {
throw new Error('Dashboard name is provided but dashboard creation is disabled');
}
if (props.dashboard !== false) {
this.dash = new cloudwatch.Dashboard(this, 'Dashboard', { dashboardName: props.dashboardName });
new CfnOutput(this, 'WatchfulDashboard', {
value: linkForDashboard(this.dash),
});
}
}