Skip to content

Commit

Permalink
feat: ok and alert actions can be configured
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanfreitagrwe authored and stefanfreitag committed Jul 25, 2024
1 parent 2d1b5f4 commit 42046dd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": "latest"
},
"ghcr.io/devcontainers/features/terraform:1": {
"version": "1.6.2",
"version": "1.9.3",
"tflint": "0.48.0",
"installTFsec": "true",
"installTerraformDocs": "true"
Expand Down
4 changes: 2 additions & 2 deletions examples/01_default_configuration/versions.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
terraform {
required_version = "~>1.5"
required_version = "~>1.9"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~>5.32"
version = "~>5.59"
}
}
}
7 changes: 3 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ resource "aws_cloudwatch_log_group" "rds_health_lambda_log_groups" {
tags = var.tags
}


resource "aws_cloudwatch_metric_alarm" "this" {
for_each = toset(local.rds_names)
namespace = "Custom/RDS"
Expand All @@ -137,9 +136,9 @@ resource "aws_cloudwatch_metric_alarm" "this" {
statistic = "Average"
threshold = 0
treat_missing_data = var.cloudwatch_alarms_treat_missing_data
alarm_actions = []
insufficient_data_actions = []
ok_actions = []
alarm_actions = var.alarm_actions
insufficient_data_actions = var.insufficient_data_actions
ok_actions = var.ok_actions
dimensions = {
DBInstanceIdentifier = each.key
}
Expand Down
17 changes: 17 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ variable "rds_arns" {
default = []
}

variable "alarm_actions" {
description = "The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN). Default is `null`."
type = list(string)
default = null
}

variable "insufficient_data_actions" {
description = "The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN). Default is `null`."
type = list(string)
default = null
}

variable "ok_actions" {
description = "The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN)."
type = list(string)
default = null
}

variable "enable_cloudwatch_alarms" {
description = "Setup CloudWatch alarms for the RDS state. For each state a separate alarm will be created. Default is `false`."
Expand Down

0 comments on commit 42046dd

Please sign in to comment.