Skip to content

pbs/terraform-aws-cloudwatch-alarms-module-v2

Repository files navigation

PBS TF CloudWatch Alarms Module v2

Installation

Using the Repo Source

Use this URL for the source of the module. See the usage examples below for more details.

github.com/pbs/terraform-aws-cloudwatch-alarms-module-v2?ref=0.0.2

Alternative Installation Methods

More information can be found on these install methods and more in the documentation here.

Usage

This module provisions multiple CloudWatch alarms and can send notifications to Slack via SNS topics and AmazonQ.

It is an opinionated module that will configure CloudWatch alarms with as little manual configuration as possible. See the examples located in the examples folder to see what kind of resources are supported.

Integrate this module like so:

module "alarm" {
  source = "github.com/pbs/terraform-aws-cloudwatch-alarms-module-v2?ref=0.0.2"

  name       = "test-app"
  alarms     = [
    {
      name             = "error-count-alarm"
      description      = "Alarm if more than 5 errors in 1 minute"
      slack_channel_id = "C12345678"
      log_group_name   = "/ecs/test-app-log-group-name"
      pattern          = "ERROR"
      metric_name      = "error-count"
      metric_namespace = "test-app"
      metric_value     = "1"
      alarm_threshold  = 5
      alarm_period     = 60
      alarm_statistic  = "Sum"
      treat_missing_data = "notBreaching"
    }
  ]

  # Tagging Parameters
  organization = var.organization
  environment  = var.environment
  product      = var.product
  owner        = var.owner
  repo         = var.repo

  # Optional Parameters
}

Adding This Version of the Module

If this repo is added as a subtree, then the version of the module should be close to the version shown here:

0.0.2

Note, however that subtrees can be altered as desired within repositories.

Further documentation on usage can be found here.

Below is automatically generated documentation on this Terraform module using terraform-docs


Requirements

Name Version
terraform >= 1.3.2
aws >= 5.61.0

Providers

Name Version
aws 6.3.0

Modules

No modules.

Resources

Name Type
aws_chatbot_slack_channel_configuration.slack resource
aws_cloudwatch_log_metric_filter.filter resource
aws_cloudwatch_metric_alarm.alarm resource
aws_sns_topic.topic resource
aws_caller_identity.current data source
aws_default_tags.common_tags data source

Inputs

Name Description Type Default Required
environment Environment (sharedtools, dev, staging, qa, prod) string n/a yes
organization Organization using this module. Used to prefix tags so that they are easily identified as being from your organization string n/a yes
owner Tag used to group resources according to owner string n/a yes
product Tag used to group resources according to product string n/a yes
repo Tag used to point to the repo using this module string n/a yes
alarms List of CloudWatch alert configurations for Slack notifications.

Each object supports the following attributes:
- name: (string) Unique name for the alert
- description: (string) Description of the alarm
- slack_channel_id: (string) Slack channel ID to send notifications to
- log_group_name: (string) CloudWatch log group to monitor
- pattern: (string) Filter pattern for log events https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html
- metric_name: (string) Name of the custom metric
- metric_namespace: (string) Namespace for the custom metric
- metric_value: (string) Value to publish to the metric when the pattern matches (usually "1")
- alarm_threshold: (number) Threshold for triggering the alarm
- alarm_period: (number) Period (in seconds) over which data is evaluated
- alarm_statistic: (string) Statistic to apply to the metric. Possible values: "Sum", "Average", "Minimum", "Maximum", "SampleCount"
- treat_missing_data: (string) How to treat missing data. Possible values: "breaching", "notBreaching", "ignore", "missing"
list(object({
name = string
description = string
slack_channel_id = string
log_group_name = string
pattern = string
metric_name = string
metric_namespace = string
metric_value = string
alarm_threshold = number
alarm_period = number
alarm_statistic = string
treat_missing_data = string
}))
[] no
chatbot_role_arn ARN of the IAM role for AWS Chatbot string null no
name Name of the alarm being created. Defaults to product if null. string null no
slack_team_id Slack team ID for AWS Chatbot integration string "T0Y7JC3PF" no
tags Extra tags map(string) {} no

Outputs

Name Description
arns ARN of the alarm provisioned
names Name of the alarm provisioned

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published