cloudwatch
Creates CloudWatch log groups, metric filters, metric alarms, composite alarms, and dashboards.
Manages the full CloudWatch observability stack: log groups with configurable retention and KMS encryption, metric filters that emit custom metrics from log patterns, threshold-based metric alarms with SNS actions, composite alarms for correlated alerting, and JSON-body dashboards.
Usage
module "cloudwatch" {
source = "hcassc.jfrog.io/iac-terraform-modules-virtual/observability/cloudwatch/aws"
version = "0.1.0"
log_groups = {
app = { name = "/app/prod", retention_in_days = 30 }
}
alarms = {
high_error_rate = {
alarm_name = "prod-high-error-rate"
namespace = "AWS/ApplicationELB"
metric_name = "HTTPCode_Target_5XX_Count"
threshold = 100
comparison_operator = "GreaterThanThreshold"
alarm_actions = [module.sns.topic_arns["ops"]]
}
}
}
Requirements
Providers
Resources
| Name |
Description |
Type |
Default |
Required |
| alarms |
Map of CloudWatch metric alarms |
map(object({ alarm_name = string alarm_description = optional(string, "") namespace = string metric_name = string statistic = optional(string, "Sum") period = optional(number, 300) evaluation_periods = optional(number, 1) threshold = number comparison_operator = string treat_missing_data = optional(string, "notBreaching") dimensions = optional(map(string), {}) alarm_actions = optional(list(string), []) ok_actions = optional(list(string), []) datapoints_to_alarm = optional(number, null) })) |
{} |
no |
| composite_alarms |
Map of composite CloudWatch alarms |
map(object({ alarm_name = string alarm_description = optional(string, "") alarm_rule = string alarm_actions = optional(list(string), []) ok_actions = optional(list(string), []) })) |
{} |
no |
| dashboards |
Map of CloudWatch dashboard name to JSON body |
map(string) |
{} |
no |
| log_groups |
Map of CloudWatch log groups to create |
map(object({ name = string retention_in_days = optional(number, 90) kms_key_id = optional(string, null) skip_destroy = optional(bool, false) })) |
{} |
no |
| metric_filters |
Map of metric filters on log groups |
map(object({ log_group_key = string pattern = string metric_name = string metric_namespace = string metric_value = optional(string, "1") default_value = optional(string, "0") })) |
{} |
no |
| tags |
Resource tags to apply to all resources |
map(string) |
{} |
no |
Outputs