Skip to content

Commit

Permalink
add tags attribute to cloudmetrics resource
Browse files Browse the repository at this point in the history
  • Loading branch information
bennsimon committed Nov 28, 2024
1 parent e5fdbc9 commit 6025fef
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ resource "aws_cloudwatch_metric_alarm" "db-connections" {
dimensions = {
DBInstanceIdentifier = (length(var.postgresql_source_snapshot_identifier) == 0 && var.postgresql_replicate_source_db == null) ? aws_db_instance.blank-database[0].identifier : var.postgresql_replicate_source_db != null ? aws_db_instance.replica-database[0].identifier : aws_db_instance.from-snapshot[0].identifier
}

tags = {
Name = var.postgresql_name
OwnerList = var.postgresql_owner
EnvironmentList = var.postgresql_env
ProjectList = var.postgresql_project
DeploymentType = var.postgresql_deployment_type
EndDate = var.postgresql_end_date
Group = "${var.postgresql_project}-${var.postgresql_env}"
}
}

resource "aws_cloudwatch_metric_alarm" "cpu_utilization_too_high" {
Expand All @@ -225,6 +235,16 @@ resource "aws_cloudwatch_metric_alarm" "cpu_utilization_too_high" {
dimensions = {
DBInstanceIdentifier = (length(var.postgresql_source_snapshot_identifier) == 0 && var.postgresql_replicate_source_db == null) ? aws_db_instance.blank-database[0].identifier : var.postgresql_replicate_source_db != null ? aws_db_instance.replica-database[0].identifier : aws_db_instance.from-snapshot[0].identifier
}

tags = {
Name = var.postgresql_name
OwnerList = var.postgresql_owner
EnvironmentList = var.postgresql_env
ProjectList = var.postgresql_project
DeploymentType = var.postgresql_deployment_type
EndDate = var.postgresql_end_date
Group = "${var.postgresql_project}-${var.postgresql_env}"
}
}

resource "aws_cloudwatch_metric_alarm" "free_storage_space_too_low" {
Expand All @@ -243,6 +263,16 @@ resource "aws_cloudwatch_metric_alarm" "free_storage_space_too_low" {
dimensions = {
DBInstanceIdentifier = (length(var.postgresql_source_snapshot_identifier) == 0 && var.postgresql_replicate_source_db == null) ? aws_db_instance.blank-database[0].identifier : var.postgresql_replicate_source_db != null ? aws_db_instance.replica-database[0].identifier : aws_db_instance.from-snapshot[0].identifier
}

tags = {
Name = var.postgresql_name
OwnerList = var.postgresql_owner
EnvironmentList = var.postgresql_env
ProjectList = var.postgresql_project
DeploymentType = var.postgresql_deployment_type
EndDate = var.postgresql_end_date
Group = "${var.postgresql_project}-${var.postgresql_env}"
}
}

resource "aws_cloudwatch_metric_alarm" "freeable_memory_too_low" {
Expand All @@ -261,6 +291,16 @@ resource "aws_cloudwatch_metric_alarm" "freeable_memory_too_low" {
dimensions = {
DBInstanceIdentifier = (length(var.postgresql_source_snapshot_identifier) == 0 && var.postgresql_replicate_source_db == null) ? aws_db_instance.blank-database[0].identifier : var.postgresql_replicate_source_db != null ? aws_db_instance.replica-database[0].identifier : aws_db_instance.from-snapshot[0].identifier
}

tags = {
Name = var.postgresql_name
OwnerList = var.postgresql_owner
EnvironmentList = var.postgresql_env
ProjectList = var.postgresql_project
DeploymentType = var.postgresql_deployment_type
EndDate = var.postgresql_end_date
Group = "${var.postgresql_project}-${var.postgresql_env}"
}
}

resource "aws_cloudwatch_log_metric_filter" "slow_query_metric_filter" {
Expand Down Expand Up @@ -289,5 +329,15 @@ resource "aws_cloudwatch_metric_alarm" "slow_query_metric_alarm" {
threshold = var.postgresql_slow_query_threshold
statistic = var.postgresql_slow_query_statistic
alarm_actions = var.postgresql_alarm_actions
tags = { notification_type = var.postgresql_slow_query_notification_type, severity = var.postgresql_slow_query_severity }
tags = {
Name = var.postgresql_name
OwnerList = var.postgresql_owner
EnvironmentList = var.postgresql_env
ProjectList = var.postgresql_project
DeploymentType = var.postgresql_deployment_type
EndDate = var.postgresql_end_date
Group = "${var.postgresql_project}-${var.postgresql_env}"
notification_type = var.postgresql_slow_query_notification_type
severity = var.postgresql_slow_query_severity
}
}

0 comments on commit 6025fef

Please sign in to comment.