I'm trying to create a cloudwatch alarm that alerts if a bucket receives a burst of uploads the alarm is triggered and an sns email is sent. I chose the Postrequests s3 metrics
Here is my terraform resource:
resource "aws_cloudwatch_metric_alarm" "augmentation_brusque_evenement" {
alarm_name = "augmentation-brusque-events"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "PostRequests"
namespace = "AWS/S3"
period = "120"
statistic = "Sum"
unit = "Count"
datapoints_to_alarm = "1"
threshold = var.s3_threshold
alarm_actions = var.sns_arn
ok_actions = var.sns_arn
dimensions = {
BucketName = aws_s3_bucket.bucket_test.id
}
}
The thought process behind this is if the number if post requests over a period of 2 minutes surpasses the set threshold an email will be sent by an already created and tested sns topic.
The terraform code works ok and the alarm is created but it's always in an insufficient data state, I tried uploading files to the s3 bucket through the console, using terraform and through the cli but none of these methods seemed to changed the alarm state. I have tried the same alarm but with the Allrequests metric but with no luck.
Any insight of what might be the problem with my code or thought process would be greatly appreciated and I'm open to suggestions of better ways to possibly create this alarm.
Thanks in advance