Setting up database connection alarm using Terraform with database connection formula

Viewed 117

I am trying to setup the Cloudwatch alarm for database connections in Terraform.

`resource "aws_cloudwatch_metric_alarm" "db_connections" {
  alarm_name          = "db_connections"
  comparison_operator = "GreaterThanThreshold"
  evaluation_periods  = "1"
  metric_name         = "DatabaseConnections"
  namespace           = "AWS/RDS"
  period              = "300"
  statistic           = "Average"
  threshold           = var.db_connection_threshold
  alarm_description   = "Db connections"
  alarm_actions       = [aws_sns_topic.topic.arn]
 

  dimensions = {
    DBInstanceIdentifier = "${var.db_instance_id}"
  }
}
`

What i am trying to achieve is to setup using this formula GREATEST({log(DBInstanceClassMemory/805306368,2)*45},{log(DBInstanceClassMemory/8187281408,2)*1000}). If it is greater than 90 percent then the Alarm rises. Is there any possibility for that in Terraform. I tried with giving var threshold =formula/100 and it didn't work. Any suggestions? Thanks

0 Answers
Related