I have below code for setting up alarm for AWS glue job using CDK:
import { aws_cloudwatch as cloudwatch, aws_events as events } from 'aws-cdk-lib';
// jobName. This is our AWS Glue script to monitor
const jobFailedRule = new Rule(scope, '{DVRD replication} JobFailureRule', {
eventPattern: {
source: ['aws.glue'],
detailType: ['Glue Job State Change'],
detail: {
state: ['FAILED', 'TIMEOUT', 'ERROR'],
jobName: [DVRD replication],
},
},
})
//cloudwatch metric
const numFailedJobsMetric = new cloudwatch.Metric({
namespace: 'AWS/Events',
metricName: 'TriggeredRules',
statistic: 'Sum',
dimensionsMap: {
RuleName: jobFailedRule.ruleName,
},
})
//cloudwatch alarm
const numFailedJobsAlarm = new cloudwatch.Alarm(scope, '{DVRD replication} numFailedJobsAlarm', {
metric: numFailedJobsMetric,
threshold: 1,
evaluationPeriods: 1,
});
Now i want to setup SNS email notification for this alarm but not sure how to do it.