Skip to content

Commit

Permalink
Merge pull request #27 from steve-stonehouse/master
Browse files Browse the repository at this point in the history
Adding variables for alarm evaluation periods.
  • Loading branch information
raymondbutcher authored Dec 20, 2018
2 parents 899f38d + deb7686 commit 1082263
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres96_parameter_
| azs | List of AZs to use | list | - | yes |
| backup_retention_period | How long to keep backups for (in days) | string | `7` | no |
| cw_alarms | Whether to enable CloudWatch alarms - requires `cw_sns_topic` is specified | string | `false` | no |
| cw_eval_period_connections | Evaluation period for the DB connections alarms | string | `1` | no |
| cw_eval_period_cpu | Evaluation period for the DB CPU alarms | string | `2` | no |
| cw_eval_period_replica_lag | Evaluation period for the DB replica lag alarm | string | `5` | no |
| cw_max_conns | Connection count beyond which to trigger a CloudWatch alarm | string | `500` | no |
| cw_max_cpu | CPU threshold above which to alarm | string | `85` | no |
| cw_max_replica_lag | Maximum Aurora replica lag in milliseconds above which to alarm | string | `2000` | no |
Expand Down
10 changes: 5 additions & 5 deletions alarms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "aws_cloudwatch_metric_alarm" "alarm_rds_DatabaseConnections_writer" {
count = "${var.cw_alarms ? 1 : 0}"
alarm_name = "${aws_rds_cluster.default.id}-alarm-rds-writer-DatabaseConnections"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
evaluation_periods = "${var.cw_eval_period_connections}"
metric_name = "DatabaseConnections"
namespace = "AWS/RDS"
period = "60"
Expand All @@ -22,7 +22,7 @@ resource "aws_cloudwatch_metric_alarm" "alarm_rds_DatabaseConnections_reader" {
count = "${var.cw_alarms && var.replica_count > 0 ? 1 : 0}"
alarm_name = "${aws_rds_cluster.default.id}-alarm-rds-reader-DatabaseConnections"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
evaluation_periods = "${var.cw_eval_period_connections}"
metric_name = "DatabaseConnections"
namespace = "AWS/RDS"
period = "60"
Expand All @@ -42,7 +42,7 @@ resource "aws_cloudwatch_metric_alarm" "alarm_rds_CPU_writer" {
count = "${var.cw_alarms ? 1 : 0}"
alarm_name = "${aws_rds_cluster.default.id}-alarm-rds-writer-CPU"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "2"
evaluation_periods = "${var.cw_eval_period_cpu}"
metric_name = "CPUUtilization"
namespace = "AWS/RDS"
period = "60"
Expand All @@ -62,7 +62,7 @@ resource "aws_cloudwatch_metric_alarm" "alarm_rds_CPU_reader" {
count = "${var.cw_alarms && var.replica_count > 0 ? 1 : 0}"
alarm_name = "${aws_rds_cluster.default.id}-alarm-rds-reader-CPU"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "2"
evaluation_periods = "${var.cw_eval_period_cpu}"
metric_name = "CPUUtilization"
namespace = "AWS/RDS"
period = "60"
Expand All @@ -82,7 +82,7 @@ resource "aws_cloudwatch_metric_alarm" "alarm_rds_replica_lag" {
count = "${var.cw_alarms && var.replica_count > 0 ? 1 : 0}"
alarm_name = "${aws_rds_cluster.default.id}-alarm-rds-reader-AuroraReplicaLag"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "5"
evaluation_periods = "${var.cw_eval_period_replica_lag}"
metric_name = "AuroraReplicaLag"
namespace = "AWS/RDS"
period = "60"
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ variable "cw_max_replica_lag" {
description = "Maximum Aurora replica lag in milliseconds above which to alarm"
}

variable "cw_eval_period_connections" {
type = "string"
default = "1"
description = "Evaluation period for the DB connections alarms"
}

variable "cw_eval_period_cpu" {
type = "string"
default = "2"
description = "Evaluation period for the DB CPU alarms"
}

variable "cw_eval_period_replica_lag" {
type = "string"
default = "5"
description = "Evaluation period for the DB replica lag alarm"
}

variable "engine" {
type = "string"
default = "aurora"
Expand Down

0 comments on commit 1082263

Please sign in to comment.