Patterned Designs HCL Module Registry
v0.1.0 latest View all versions

Terraform module for cloudwatch-logs on aws

View Full Documentation Usage guides, examples & best practices
module "cloudwatch-logs" {
  source  = "registry.patterneddesigns.ca/essentials/cloudwatch-logs/aws"
  version = "0.1.0"
}
log_group_name required
string

Name of the CloudWatch Log Group. Must be unique within your AWS account and region. Can contain a-z, A-Z, 0-9, '_', '-', '/', and '.' characters.

Constraints
  • Log group name must be 1-512 characters and can only contain a-z, A-Z, 0-9, '_', '-', '/', and '.' characters.
retention_in_days
number default: 30

Number of days to retain log events. Valid values: 0 (never expire), 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, 3653.

Constraints
  • Retention days must be one of the allowed CloudWatch Logs retention values.
kms_key_arn
string default: null

KMS key ARN for log encryption. When specified, the CloudWatch Log Group will be encrypted using the provided KMS key.

Constraints
  • KMS key ARN must be a valid AWS KMS key ARN.
metric_filters
list(object({ name = string pattern = string metric_name = string metric_namespace = string metric_value = optional(string, "1") })) default: null

Metric filters to create on the log group. Each filter transforms log data into CloudWatch metrics. Each object supports: - name: Unique name for the filter (required) - pattern: Filter pattern to match log events (required) - metric_name: Name of the CloudWatch metric (required) - metric_namespace: Namespace for the metric (required) - metric_value: Value to publish (optional, default: "1")

Constraints
  • Each metric filter must have a non-empty name.
tags
map(string) default: null

Tags to apply to the log group.

log_group_arn

ARN of the CloudWatch Log Group. Use this for IAM policies, subscription filters, and cross-account access.

log_group_name

Name of the CloudWatch Log Group. Use this for referencing the log group in other resources and for CloudWatch Logs Insights queries.