Has any used cloudtrail with ses notifications for...
# typescript
b
Has any used cloudtrail with ses notifications for sending any changes made to aws account
b
Cloudtrail and SNS monitoring account events? Yes I have. Anything specific you're looking to monitor and/or what questions you have?
b
Hello Brandon , im looking to send notification for all changes taking place in the company"s AWS account
b
any change whatsoever? you’ll have to look into which eventbridge rule works for that (maybe something like
"*"
like a wildcard.
this is how i’ve done that in the past, not sure if it exactly fits what you need to do, but maybe can give you a start
Copy code
const testEmail = '<mailto:test@gmail.com|test@gmail.com>';
const cloudWatchLogGroup = new aws.cloudwatch.LogGroup("cloudWatchLogGroup", {
    retentionInDays: 0, // never expire
  });  
const testTopic = new aws.sns.Topic("testTopic", {
  displayName: "test Alarm",
});
const testTopicSubscription = new aws.sns.TopicSubscription("testTopicSubscription", {
  endpoint: testEmail,
  protocol: "email",
  topic: testTopic.id,
});
const testMetricFilter = new aws.cloudwatch.LogMetricFilter("testMetricFilter", {
  pattern: `{($.eventName=ConsoleLogin) && ($.errorMessage="Failed authentication")}`,
  logGroupName: cloudWatchLogGroup.name,
  metricTransformation:
  {
    name: "AWS Test Change Metric",
    namespace: "Test/TestMetrics",
    value: "1",
  },
});
const testAlarm = new aws.cloudwatch.MetricAlarm("testAlarm", {
  name: "Test Metric Alarm",
  comparisonOperator: "GreaterThanOrEqualToThreshold",
  evaluationPeriods: 1,
  metricName: testMetricFilter.metricTransformation.name,
  namespace: testMetricFilter.metricTransformation.namespace,
  period: 5 * 60,
  statistic: "Average",
  threshold: 1,
  treatMissingData: "missing",
  alarmActions: [testTopic.arn],
  alarmDescription: "Monitoring Test Alarm",
});
b
👍
Thanks