Hi I am tried to get a list of all identifiers dynamically to have the monitoring in place. I am using below as a data source for terraform.
data “aws_db_instance” “bbgw_databases” {
db_instance_identifier = “*”
}
issue: It is not allowing me to have * to take all database identifiers. to use it in below code. So that i can use database name to use the same in cloud watch. please help me asap.
resource “aws_cloudwatch_metric_alarm” “CPUUtilization-RDS” {
alarm_name = ${data.aws_db_instance.bbgw_databases.db_name}_Database_CPU_Utilization"
comparison_operator = “GreaterThanThreshold”
evaluation_periods = “1”
metric_name = “CPUUtilization”
namespace = “AWS/RDS”
period = “300”
statistic = “Average”
threshold = “75.0”
alarm_description = “CPUUtilization”
count = length((data.aws_db_instance.bbgw_databases.db_name))
alarm_actions = [“arn:aws:sns:eu-central-1:075687792344:config-eu-central-1”]
dimensions = {
DBInstanceIdentifier = data.aws_db_instance.bbgw_databases.db_name[count.index]
}
}