Skip to content

Latest commit

 

History

History
126 lines (107 loc) · 12.3 KB

File metadata and controls

126 lines (107 loc) · 12.3 KB

AWS RDS Instance Alarms Module

This module creates AWS CloudWatch Alarms for AWS RDS Instance (Database) Metrics.

Example

# main.tf
module "rds_instance" {
  source = "git::https://github.com/lpavliuk/Terraform-Modules.git//aws_rds_instance_mysql"

  name                       = local.codename
  instance_type              = "db.t3.micro"
  storage_size_gb            = "20"
  storage_type               = "gp3"
  mysql_engine_version       = "8.0.33"
  vpc_id                     = local.vpc_id
  rds_subnet_group_id        = local.rds_subnet_group_id

  manage_master_user_pswd           = true
  is_private                        = true
  multi_az                          = true
  enable_enhanced_monitoring        = true
  enable_auto_minor_version_upgrade = true
  backup_retention_period_days      = 0                     # [!] Disabled as AWS Backup is used!
  backup_window_utc_period          = "14:00-16:00"         # UTC => 01:00-03:00 Sydney AEDT
  maintenance_window_utc_period     = "Sat:16:00-Sat:18:00" # UTC => Sun 03:00-05:00 Sydney AEDT

  cloudwatch_logs_exports               = ["error"]
  cloudwatch_logs_retention_period_days = 30

  aws_cli_profile            = local.account_config.aws_profile
}

module "rds_instance_alarms" {
  source = "git::https://github.com/lpavliuk/Terraform-Modules.git//aws_rds_instance_alarms"

  name_prefix       = "dev-"
  db_instance_name  = module.rds_instance.name
  db_instance_class = module.rds_instance.instance_class
  sns_topic_arns    = local.notifications_sns_topic_arns

  enable_burst_balance_alarms  = false

  read_iops_too_high_threshold      = 10
  freeable_memory_too_low_threshold = 60
}

Requirements

Name Version
terraform < 2.0.0, >= 1.6.6
aws < 6.0, >= 5.22

Inputs

Name Description Type Default Required
name_prefix Prefix for CloudWatch alarms names string "" no
db_instance_name RDS Instance Name alarms will be created for string n/a yes
db_instance_class RDS Instance Class for CloudWatch alarms names string n/a yes
sns_topic_arns SNS Topic ARNs attached to CloudWatch alarms list(string) n/a yes
evaluation_periods Evaluation period over which to use when triggering alarms number 5 no
statistics_period Number of seconds that make each statistic period number 60 no
enable_cpu_utilization_alarms Create CPU Utilization alarms bool true no
enable_cpu_credit_balance_alarms Create CPU Credit Balance alarms bool true no
enable_read_iops_alarms Create Read IOPS alarms bool true no
enable_burst_balance_alarms Create Burst Balance alarms bool true no
enable_disk_queue_depth_alarms Create Disk Queue Depth alarms bool true no
enable_disk_free_storage_space_alarms Create Disk Free Storage Space alarms bool true no
enable_freeable_memory_alarms Create Freeable Memory alarms bool true no
enable_memory_swap_usage_alarms Create Swap Usage alarms bool true no
enable_db_connections_alarms Create Database Connections alarms bool true no
cpu_utilization_too_high_threshold The maximum percentage of CPU utilization number 80 no
cpu_credit_balance_too_low_threshold The minimum number of CPU credits (t2 instances only) available number 50 no
read_iops_too_high_threshold The number of IOPS is meant to be suspicious number 100 no
burst_balance_too_low_threshold The minimum percent of General Purpose SSD (gp2) burst-bucket I/O credits available number 90 no
disk_queue_depth_too_high_threshold The maximum number of outstanding IOs (read/write requests) waiting to access the disk number 64 no
disk_free_storage_space_threshold The minimum amount of available storage space in Megabytes number 2000 no
freeable_memory_too_low_threshold The minimum amount of available random access memory in Megabytes number 100 no
memory_swap_usage_too_high_threshold The maximum amount of swap space used on the DB instance in Megabytes number 256 no
db_connections_limit_threshold The maximum percent of connections connected to the DB instance number 80 no

Outputs

Name Description
cpu_utilization_too_high_alarm_arn 'CPU Utilization Too High' alarm's ARN
cpu_utilization_too_high_alarm_name 'CPU Utilization Too High' alarm's Name
cpu_utilization_too_high_alarm_threshold 'CPU Utilization Too High' alarm's Threshold
cpu_credit_balance_too_low_alarm_arn 'CPU Credit Balance' alarm's ARN
cpu_credit_balance_too_low_alarm_name 'CPU Credit Balance' alarm's Name
cpu_credit_balance_too_low_alarm_threshold 'CPU Credit Balance' alarm's Threshold
read_iops_too_high_alarm_arn 'Read IOPS' alarm's ARN
read_iops_too_high_alarm_name 'Read IOPS' alarm's Name
read_iops_too_high_alarm_threshold 'Read IOPS' alarm's Threshold
burst_balance_too_low_alarm_arn 'Burst Balance' alarm's ARN
burst_balance_too_low_alarm_name 'Burst Balance' alarm's Name
burst_balance_too_low_alarm_threshold 'Burst Balance' alarm's Threshold
disk_queue_depth_too_high_alarm_arn 'Disk Queue Depth' alarm's ARN
disk_queue_depth_too_high_alarm_name 'Disk Queue Depth' alarm's Name
disk_queue_depth_too_high_alarm_threshold 'Disk Queue Depth' alarm's Threshold
freeable_memory_too_low_alarm_arn 'Freeable Memory' alarm's ARN
freeable_memory_too_low_alarm_name 'Freeable Memory' alarm's Name
freeable_memory_too_low_alarm_threshold 'Freeable Memory' alarm's Threshold
disk_free_storage_space_threshold_alarm_arn 'Disk Free Storage Space' alarm's ARN
disk_free_storage_space_threshold_alarm_name 'Disk Free Storage Space' alarm's Name
disk_free_storage_space_alarm_threshold 'Disk Free Storage Space' alarm's Threshold
memory_swap_usage_too_high_alarm_arn 'Swap Usage' alarm's ARN
memory_swap_usage_too_high_alarm_name 'Swap Usage' alarm's Name
memory_swap_usage_too_high_alarm_threshold 'Swap Usage' alarm's Threshold
db_connections_limit_alarm_arn 'Database Connections' alarm's ARN
db_connections_limit_alarm_name 'Database Connections' alarm's Name
db_connections_limit_alarm_threshold 'Database Connections' alarm's Threshold

Resources

Name Type
aws_cloudwatch_metric_alarm.this resource
aws_db_event_subscription.this resource