-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fa55dc
commit 51db222
Showing
6 changed files
with
158 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.terraform | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,100 @@ | ||
resource "aws_cloudwatch_metric_alarm" "alarm_rds_DatabaseConnections_writer" { | ||
count = "${var.cw_alarms ? 1 : 0}" | ||
count = var.cw_alarms ? 1 : 0 | ||
alarm_name = "${aws_rds_cluster.default.id}-alarm-rds-writer-DatabaseConnections" | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
evaluation_periods = "1" | ||
metric_name = "DatabaseConnections" | ||
namespace = "AWS/RDS" | ||
period = "60" | ||
statistic = "Sum" | ||
threshold = "${var.cw_max_conns}" | ||
threshold = var.cw_max_conns | ||
alarm_description = "RDS Maximum connection Alarm for ${aws_rds_cluster.default.id} writer" | ||
alarm_actions = ["${var.cw_sns_topic}"] | ||
ok_actions = ["${var.cw_sns_topic}"] | ||
alarm_actions = [var.cw_sns_topic] | ||
ok_actions = [var.cw_sns_topic] | ||
|
||
dimensions { | ||
DBClusterIdentifier = "${aws_rds_cluster.default.id}" | ||
dimensions = { | ||
DBClusterIdentifier = aws_rds_cluster.default.id | ||
Role = "WRITER" | ||
} | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "alarm_rds_DatabaseConnections_reader" { | ||
count = "${var.cw_alarms && var.replica_count > 0 ? 1 : 0}" | ||
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" | ||
metric_name = "DatabaseConnections" | ||
namespace = "AWS/RDS" | ||
period = "60" | ||
statistic = "Maximum" | ||
threshold = "${var.cw_max_conns}" | ||
threshold = var.cw_max_conns | ||
alarm_description = "RDS Maximum connection Alarm for ${aws_rds_cluster.default.id} reader(s)" | ||
alarm_actions = ["${var.cw_sns_topic}"] | ||
ok_actions = ["${var.cw_sns_topic}"] | ||
alarm_actions = [var.cw_sns_topic] | ||
ok_actions = [var.cw_sns_topic] | ||
|
||
dimensions { | ||
DBClusterIdentifier = "${aws_rds_cluster.default.id}" | ||
dimensions = { | ||
DBClusterIdentifier = aws_rds_cluster.default.id | ||
Role = "READER" | ||
} | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "alarm_rds_CPU_writer" { | ||
count = "${var.cw_alarms ? 1 : 0}" | ||
count = var.cw_alarms ? 1 : 0 | ||
alarm_name = "${aws_rds_cluster.default.id}-alarm-rds-writer-CPU" | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
evaluation_periods = "2" | ||
metric_name = "CPUUtilization" | ||
namespace = "AWS/RDS" | ||
period = "60" | ||
statistic = "Maximum" | ||
threshold = "${var.cw_max_cpu}" | ||
threshold = var.cw_max_cpu | ||
alarm_description = "RDS CPU Alarm for ${aws_rds_cluster.default.id} writer" | ||
alarm_actions = ["${var.cw_sns_topic}"] | ||
ok_actions = ["${var.cw_sns_topic}"] | ||
alarm_actions = [var.cw_sns_topic] | ||
ok_actions = [var.cw_sns_topic] | ||
|
||
dimensions { | ||
DBClusterIdentifier = "${aws_rds_cluster.default.id}" | ||
dimensions = { | ||
DBClusterIdentifier = aws_rds_cluster.default.id | ||
Role = "WRITER" | ||
} | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "alarm_rds_CPU_reader" { | ||
count = "${var.cw_alarms && var.replica_count > 0 ? 1 : 0}" | ||
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" | ||
metric_name = "CPUUtilization" | ||
namespace = "AWS/RDS" | ||
period = "60" | ||
statistic = "Maximum" | ||
threshold = "${var.cw_max_cpu}" | ||
threshold = var.cw_max_cpu | ||
alarm_description = "RDS CPU Alarm for ${aws_rds_cluster.default.id} reader(s)" | ||
alarm_actions = ["${var.cw_sns_topic}"] | ||
ok_actions = ["${var.cw_sns_topic}"] | ||
alarm_actions = [var.cw_sns_topic] | ||
ok_actions = [var.cw_sns_topic] | ||
|
||
dimensions { | ||
DBClusterIdentifier = "${aws_rds_cluster.default.id}" | ||
dimensions = { | ||
DBClusterIdentifier = aws_rds_cluster.default.id | ||
Role = "READER" | ||
} | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "alarm_rds_replica_lag" { | ||
count = "${var.cw_alarms && var.replica_count > 0 ? 1 : 0}" | ||
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" | ||
metric_name = "AuroraReplicaLag" | ||
namespace = "AWS/RDS" | ||
period = "60" | ||
statistic = "Maximum" | ||
threshold = "${var.cw_max_replica_lag}" | ||
threshold = var.cw_max_replica_lag | ||
alarm_description = "RDS CPU Alarm for ${aws_rds_cluster.default.id}" | ||
alarm_actions = ["${var.cw_sns_topic}"] | ||
ok_actions = ["${var.cw_sns_topic}"] | ||
alarm_actions = [var.cw_sns_topic] | ||
ok_actions = [var.cw_sns_topic] | ||
|
||
dimensions { | ||
DBClusterIdentifier = "${aws_rds_cluster.default.id}" | ||
dimensions = { | ||
DBClusterIdentifier = aws_rds_cluster.default.id | ||
Role = "READER" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
// The 'writer' endpoint for the cluster | ||
output "cluster_endpoint" { | ||
value = "${aws_rds_cluster.default.endpoint}" | ||
value = aws_rds_cluster.default.endpoint | ||
} | ||
|
||
// Comma separated list of all DB instance endpoints running in cluster | ||
output "all_instance_endpoints_list" { | ||
value = ["${aws_rds_cluster_instance.cluster_instance_0.endpoint}", "${aws_rds_cluster_instance.cluster_instance_n.*.endpoint}"] | ||
value = [aws_rds_cluster_instance.cluster_instance_0.endpoint, aws_rds_cluster_instance.cluster_instance_n.*.endpoint] | ||
} | ||
|
||
// A read-only endpoint for the Aurora cluster, automatically load-balanced across replicas | ||
output "reader_endpoint" { | ||
value = "${aws_rds_cluster.default.reader_endpoint}" | ||
value = aws_rds_cluster.default.reader_endpoint | ||
} | ||
|
||
// Cluster ARN - can use when defining centralised backup | ||
output "cluster_arn" { | ||
value = "${aws_rds_cluster.default.arn}" | ||
value = aws_rds_cluster.default.arn | ||
} | ||
|
||
// Cluster ID - useful to any resources requiring cluster's ID, e.g. rds_cluster_role_association | ||
output "cluster_id" { | ||
value = "${aws_rds_cluster.default.id}" | ||
} | ||
value = aws_rds_cluster.default.id | ||
} | ||
|
Oops, something went wrong.