Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ AWS_PROFILE=cloud-snitch-dev npx cdk deploy '*-dev'
## Observability

The CDK deploys a CloudWatch dashboard in us-east-1 with key metrics for all regions.

Alarms are created in each region and will send notifications to an SNS topic in each region. To receive notifications, you should subscribe to the SNS topic in each region.
17 changes: 17 additions & 0 deletions aws/lib/regional-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
aws_certificatemanager as acm,
aws_cloudfront as cloudfront,
aws_cloudfront_origins as origins,
aws_cloudwatch as cw,
aws_cloudwatch_actions as cw_actions,
aws_ecr_assets as ecr_assets,
aws_events as events,
aws_events_targets as events_targets,
Expand All @@ -16,6 +18,7 @@ import {
aws_s3 as s3,
aws_s3_deployment as s3deploy,
aws_ses as ses,
aws_sns as sns,
aws_sqs as sqs,
aws_route53_targets as route53_targets,
Duration,
Expand Down Expand Up @@ -64,6 +67,8 @@ export class RegionalStack extends Stack {
constructor(scope: Construct, id: string, props: Props) {
super(scope, id, props);

const alarmTopic = new sns.Topic(this, 'AlarmTopic');

// Unfortunately CloudFormation templates must be made available via public S3 bucket:
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stack.html#cfn-cloudformation-stack-templateurl
const publicS3BucketName =
Expand Down Expand Up @@ -123,6 +128,12 @@ export class RegionalStack extends Stack {
const dlq = new sqs.Queue(this, 'DeadLetterQueue', {
queueName: `${queueName}-DLQ`,
});
const dlqAlarm = new cw.Alarm(this, 'DeadLetterQueueAlarm', {
Copy link

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a 'description' field to the CloudWatch alarm configuration to provide more context for what triggers the alarm, which can aid in troubleshooting and monitoring.

Copilot uses AI. Check for mistakes.
metric: dlq.metricApproximateNumberOfMessagesVisible(),
threshold: 1,
evaluationPeriods: 1,
});
dlqAlarm.addAlarmAction(new cw_actions.SnsAction(alarmTopic));

const queue = new sqs.Queue(this, 'Queue', {
deadLetterQueue: {
Expand Down Expand Up @@ -255,6 +266,12 @@ export class RegionalStack extends Stack {
const dlq = new sqs.Queue(this, 'StripeEventHandlerDLQ', {
queueName: `CloudSnitchStripeEventHandler-DLQ`,
});
const dlqAlarm = new cw.Alarm(this, 'StripeEventHandlerDLQAlarm', {
metric: dlq.metricApproximateNumberOfMessagesVisible(),
threshold: 1,
evaluationPeriods: 1,
});
dlqAlarm.addAlarmAction(new cw_actions.SnsAction(alarmTopic));

const stripeEventHandler = new lambda.DockerImageFunction(this, 'StripeEventHandler', {
architecture: lambda.Architecture.ARM_64,
Expand Down
Loading