Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloudwatch alarm to monitor key rotation lambda for failures #14

Merged
merged 1 commit into from
Dec 20, 2023
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
18 changes: 17 additions & 1 deletion modules/iam-users/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,23 @@ resource "aws_lambda_function" "key_rotation" {
}
}
}

# Create a cloudwatch alarm that monitors IAM users lambda failures
resource "aws_cloudwatch_metric_alarm" "key_rotation_lambda_function" {
alarm_name = var.alarm_name
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "Errors"
namespace = "AWS/Lambda"
period = "60"
statistic = "Sum"
threshold = "1"
datapoints_to_alarm = "1"
alarm_description = "Monitor IAM users lambda for errors"
alarm_actions = [var.sns_arn]
dimensions = {
FunctionName = var.function_name
}
}
# Create a Cloud watch event rule for every 5 minutes
resource "aws_cloudwatch_event_rule" "every_hour" {
name = "every-hour"
Expand Down
7 changes: 7 additions & 0 deletions modules/iam-users/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ variable "role_name" {
variable "policy_name" {
description = "Name of the policy created for the lambda function"
}
variable "alarm_name" {
description = "name of the cloudwatch alarm"
}

variable "sns_arn" {
description = "name of the sns topic arn for cloudwatch arn"
}
Loading