generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7881 from ministryofjustice/DBA-766
Dba 766
- Loading branch information
Showing
11 changed files
with
140 additions
and
22 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 |
---|---|---|
|
@@ -137,5 +137,6 @@ locals { | |
user_target_endpoint = { | ||
write_database = "DMDNDA" | ||
} | ||
is-production = local.is-production | ||
} | ||
} |
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 |
---|---|---|
|
@@ -135,6 +135,7 @@ locals { | |
user_target_endpoint = { | ||
write_database = "PRENDA" | ||
} | ||
is-production = local.is-production | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -135,5 +135,6 @@ locals { | |
user_target_endpoint = { | ||
write_database = "STGNDA" | ||
} | ||
is-production = local.is-production | ||
} | ||
} |
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 |
---|---|---|
|
@@ -134,5 +134,6 @@ locals { | |
read_database = "TSTNDA" | ||
} | ||
user_target_endpoint = {} | ||
is-production = local.is-production | ||
} | ||
} |
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
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
109 changes: 109 additions & 0 deletions
109
terraform/environments/delius-core/modules/components/dms/cloudwatch-alarms.tf
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,109 @@ | ||
# SNS topic for monitoring to send alarms to | ||
resource "aws_sns_topic" "dms_alerting" { | ||
name = "delius-dms-alerting" | ||
kms_master_key_id = var.account_config.kms_keys.general_shared | ||
} | ||
|
||
locals { | ||
aws_dms_replication_tasks = merge( | ||
try(var.dms_config.user_target_endpoint.write_database, null) == null ? {} : { | ||
(aws_dms_replication_task.user_inbound_replication[0].replication_task_arn) = aws_dms_replication_task.user_inbound_replication[0].replication_task_id | ||
}, | ||
{for k in keys(local.client_account_map) : | ||
(aws_dms_replication_task.business_interaction_inbound_replication[k].replication_task_arn) => aws_dms_replication_task.business_interaction_inbound_replication[k].replication_task_id | ||
}, | ||
{for k in keys(local.client_account_map) : | ||
(aws_dms_replication_task.audited_interaction_inbound_replication[k].replication_task_arn) => aws_dms_replication_task.audited_interaction_inbound_replication[k].replication_task_id | ||
}, | ||
{for k in keys(local.client_account_map) : | ||
(aws_dms_replication_task.audited_interaction_checksum_inbound_replication[k].replication_task_arn) => aws_dms_replication_task.audited_interaction_checksum_inbound_replication[k].replication_task_id | ||
}, | ||
try(var.dms_config.audit_source_endpoint.read_database, null) == null ? {} : { | ||
(aws_dms_replication_task.audited_interaction_outbound_replication[0].replication_task_arn) = aws_dms_replication_task.audited_interaction_outbound_replication[0].replication_task_id | ||
}, | ||
{for k in keys(local.client_account_map) : | ||
(aws_dms_replication_task.user_outbound_replication[k].replication_task_arn) => aws_dms_replication_task.user_outbound_replication[k].replication_task_id | ||
}, | ||
try(var.dms_config.audit_source_endpoint.read_database, null) == null ? {} : { | ||
(aws_dms_replication_task.business_interaction_outbound_replication[0].replication_task_arn) = aws_dms_replication_task.business_interaction_outbound_replication[0].replication_task_id | ||
}, | ||
try(var.dms_config.audit_source_endpoint.read_database, null) == null ? {} : { | ||
(aws_dms_replication_task.audited_interaction_checksum_outbound_replication[0].replication_task_arn) = aws_dms_replication_task.audited_interaction_checksum_outbound_replication[0].replication_task_id | ||
}, | ||
) | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "dms_cdc_latency_source" { | ||
for_each = local.aws_dms_replication_tasks | ||
alarm_name = "dms-cdc-latency-source-${each.value}" | ||
alarm_description = "High CDC source latency for dms replication task for ${each.value}" | ||
namespace = "AWS/DMS" | ||
statistic = "Average" | ||
metric_name = "CDCLatencySource" | ||
comparison_operator = "GreaterThanThreshold" | ||
threshold = 10 | ||
evaluation_periods = 2 | ||
period = 30 | ||
actions_enabled = true | ||
alarm_actions = [aws_sns_topic.dms_alerting.arn] | ||
ok_actions = [aws_sns_topic.dms_alerting.arn] | ||
dimensions = { | ||
ReplicationInstanceIdentifier = aws_dms_replication_instance.dms_replication_instance.replication_instance_id | ||
# We only need to final element of the replication task ID (after the last :) | ||
ReplicationTaskIdentifier = split(":", each.key)[length(split(":", each.key)) - 1] | ||
} | ||
tags = var.tags | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "dms_cdc_latency_target" { | ||
for_each = local.aws_dms_replication_tasks | ||
alarm_name = "dms-cdc-latency-target-${each.value}" | ||
alarm_description = "High CDC target latency for dms replication task for ${each.value}" | ||
namespace = "AWS/DMS" | ||
statistic = "Average" | ||
metric_name = "CDCLatencyTarget" | ||
comparison_operator = "GreaterThanThreshold" | ||
threshold = 10 | ||
evaluation_periods = 2 | ||
period = 30 | ||
actions_enabled = true | ||
alarm_actions = [aws_sns_topic.dms_alerting.arn] | ||
ok_actions = [aws_sns_topic.dms_alerting.arn] | ||
dimensions = { | ||
ReplicationInstanceIdentifier = aws_dms_replication_instance.dms_replication_instance.replication_instance_id | ||
# We only need to final element of the replication task ID (after the last :) | ||
ReplicationTaskIdentifier = split(":", each.key)[length(split(":", each.key)) - 1] | ||
} | ||
tags = var.tags | ||
} | ||
|
||
# Pager duty integration | ||
|
||
# Get the map of pagerduty integration keys from the modernisation platform account | ||
data "aws_secretsmanager_secret" "pagerduty_integration_keys" { | ||
provider = aws.modernisation-platform | ||
name = "pagerduty_integration_keys" | ||
} | ||
|
||
data "aws_secretsmanager_secret_version" "pagerduty_integration_keys" { | ||
provider = aws.modernisation-platform | ||
secret_id = data.aws_secretsmanager_secret.pagerduty_integration_keys.id | ||
} | ||
|
||
# Add a local to get the keys | ||
locals { | ||
pagerduty_integration_keys = jsondecode(data.aws_secretsmanager_secret_version.pagerduty_integration_keys.secret_string) | ||
integration_key_lookup = var.dms_config.is-production ? "delius_oracle_prod_alarms" : "delius_oracle_nonprod_alarms" | ||
} | ||
|
||
# link the sns topic to the service | ||
# Non-Prod alerts channel: #delius-aws-oracle-dev-alerts | ||
# Prod alerts channel: #delius-aws-oracle-prod-alerts | ||
module "pagerduty_core_alerts" { | ||
depends_on = [ | ||
aws_sns_topic.dms_alerting | ||
] | ||
source = "github.com/ministryofjustice/modernisation-platform-terraform-pagerduty-integration?ref=v2.0.0" | ||
sns_topics = [aws_sns_topic.dms_alerting.name] | ||
pagerduty_integration_key = local.pagerduty_integration_keys[local.integration_key_lookup] | ||
} |
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
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