• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language HCL
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terraform module to create AWS Cloudwatch resources 🇺🇦

AWS Cloudwatch Terraform module

Terraform module which creates Cloudwatch resources on AWS.

Usage

Log metric filter

module "log_metric_filter" {
  source  = "terraform-aws-modules/cloudwatch/aws//modules/log-metric-filter"
  version = "~> 3.0"

  log_group_name = "my-application-logs"

  name    = "error-metric"
  pattern = "ERROR"

  metric_transformation_namespace = "MyApplication"
  metric_transformation_name      = "ErrorCount"
}

Read Filter and Pattern Syntax for explanation of pattern.

Log group

module "log_group" {
  source  = "terraform-aws-modules/cloudwatch/aws//modules/log-group"
  version = "~> 3.0"

  name              = "my-app"
  retention_in_days = 120
}

Log stream

module "log_stream" {
  source  = "terraform-aws-modules/cloudwatch/aws//modules/log-stream"
  version = "~> 3.0"

  name           = "stream1"
  log_group_name = "my-app"
}

Metric alarm

module "metric_alarm" {
  source  = "terraform-aws-modules/cloudwatch/aws//modules/metric-alarm"
  version = "~> 3.0"

  alarm_name          = "my-application-logs-errors"
  alarm_description   = "Bad errors in my-application-logs"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  evaluation_periods  = 1
  threshold           = 10
  period              = 60
  unit                = "Count"

  namespace   = "MyApplication"
  metric_name = "ErrorCount"
  statistic   = "Maximum"

  alarm_actions = ["arn:aws:sns:eu-west-1:835367859852:my-sns-queue"]
}

Metric alarms by multiple dimensions

This submodule is useful when you need to create very similar alarms where only dimensions are different (eg, multiple AWS Lambda functions), but the rest of arguments are the same.

module "metric_alarms" {
  source  = "terraform-aws-modules/cloudwatch/aws//modules/metric-alarms-by-multiple-dimensions"
  version = "~> 3.0"

  alarm_name          = "lambda-duration-"
  alarm_description   = "Lambda duration is too high"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  evaluation_periods  = 1
  threshold           = 10
  period              = 60
  unit                = "Milliseconds"

  namespace   = "AWS/Lambda"
  metric_name = "Duration"
  statistic   = "Maximum"

  dimensions = {
    "lambda1" = {
      FunctionName = "index"
    },
    "lambda2" = {
      FunctionName = "signup"
    },
  }

  alarm_actions = ["arn:aws:sns:eu-west-1:835367859852:my-sns-queue"]
}

Check out list of all AWS services that publish CloudWatch metrics for detailed information about each supported service.

CIS AWS Foundations Controls: Metrics + Alarms

module "cis_alarms" {
  source  = "terraform-aws-modules/cloudwatch/aws//modules/cis-alarms"
  version = "~> 3.0"

  log_group_name = "my-cloudtrail-logs"
  alarm_actions  = ["arn:aws:sns:eu-west-1:835367859852:my-sns-queue"]
}

AWS CloudTrail normally publishes logs into AWS CloudWatch Logs. This module creates log metric filters together with metric alarms according to CIS AWS Foundations Benchmark v1.4.0 (05-28-2021). Read more about CIS AWS Foundations Controls.

Examples

Authors

Module is maintained by Anton Babenko with help from these awesome contributors.

License

Apache 2 Licensed. See LICENSE for full details.

More Repositories

1

terraform-aws-eks

Terraform module to create Amazon Elastic Kubernetes (EKS) resources 🇺🇦
HCL
4,372
star
2

terraform-aws-vpc

Terraform module to create AWS VPC resources 🇺🇦
HCL
2,949
star
3

terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
HCL
899
star
4

terraform-aws-rds

Terraform module to create AWS RDS resources 🇺🇦
HCL
879
star
5

terraform-aws-iam

Terraform module to create AWS IAM resources 🇺🇦
HCL
779
star
6

terraform-aws-ec2-instance

Terraform module to create AWS EC2 instance(s) resources 🇺🇦
HCL
751
star
7

terraform-aws-security-group

Terraform module to create AWS Security Group resources 🇺🇦
HCL
563
star
8

terraform-aws-ecs

Terraform module to create AWS ECS resources 🇺🇦
HCL
555
star
9

terraform-aws-atlantis

Terraform module to deploy Atlantis on AWS Fargate 🇺🇦
HCL
519
star
10

terraform-aws-s3-bucket

Terraform module to create AWS S3 resources 🇺🇦
HCL
511
star
11

terraform-aws-notify-slack

Terraform module to create AWS resources for sending notifications to Slack 🇺🇦
Python
466
star
12

terraform-aws-alb

Terraform module to create AWS Application/Network Load Balancer (ALB/NLB) resources 🇺🇦
HCL
433
star
13

terraform-aws-rds-aurora

Terraform module to create AWS RDS Aurora resources 🇺🇦
HCL
384
star
14

terraform-aws-autoscaling

Terraform module to create AWS Auto Scaling resources 🇺🇦
HCL
292
star
15

terraform-aws-pricing

Terraform module which calculates price of AWS infrastructure (from Terraform state and plan) 🇺🇦
HCL
183
star
16

terraform-aws-acm

Terraform module to create AWS ACM resources 🇺🇦
HCL
182
star
17

terraform-aws-elb

Terraform module to create AWS ELB resources 🇺🇦
HCL
148
star
18

terraform-aws-apigateway-v2

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
HCL
146
star
19

terraform-aws-eventbridge

Terraform module to create AWS EventBridge resources 🇺🇦
HCL
142
star
20

terraform-aws-transit-gateway

Terraform module to create AWS Transit Gateway resources 🇺🇦
HCL
141
star
21

terraform-aws-route53

Terraform module to create AWS Route53 resources 🇺🇦
HCL
126
star
22

terraform-aws-cloudfront

Terraform module to create AWS CloudFront resources 🇺🇦
HCL
119
star
23

terraform-aws-vpn-gateway

Terraform module to create AWS VPN gateway resources 🇺🇦
HCL
111
star
24

terraform-aws-dynamodb-table

Terraform module to create AWS DynamoDB resources 🇺🇦
HCL
100
star
25

terraform-aws-sns

Terraform module to create AWS SNS resources 🇺🇦
HCL
95
star
26

terraform-aws-sqs

Terraform module to create AWS SQS resources 🇺🇦
HCL
92
star
27

terraform-aws-key-pair

Terraform module to create AWS EC2 key pair resources 🇺🇦
HCL
83
star
28

terraform-aws-redshift

Terraform module to create AWS Redshift resources 🇺🇦
HCL
81
star
29

meta

Meta-configurations for repositories, teams, files in terraform-aws-modules organization 🇺🇦
HCL
76
star
30

terraform-aws-solutions

Set of standalone and reusable AWS/DevOps solutions implemented as Terraform modules 🇺🇦
HCL
75
star
31

terraform-aws-step-functions

Terraform module to create AWS Step Functions 🇺🇦
HCL
70
star
32

terraform-aws-dms

Terraform module to create AWS DMS (Database Migration Service) resources 🇺🇦
HCL
62
star
33

terraform-aws-rds-proxy

Terraform module to create AWS RDS Proxy resources 🇺🇦
HCL
56
star
34

terraform-aws-msk-kafka-cluster

Terraform module to create AWS MSK (Managed Streaming for Kafka) resources 🇺🇦
HCL
55
star
35

terraform-aws-datadog-forwarders

Terraform module to create resources on AWS to forward logs/metrics to Datadog 🇺🇦
HCL
53
star
36

terraform-aws-eks-pod-identity

Terraform module to create AWS EKS Pod Identity resources 🇺🇦
HCL
52
star
37

terraform-aws-appsync

Terraform module to create AWS AWS AppSync resources 🇺🇦
HCL
50
star
38

terraform-aws-kms

Terraform module to create AWS KMS resources 🇺🇦
HCL
49
star
39

terraform-aws-ecr

Terraform module to create AWS ECR resources 🇺🇦
HCL
49
star
40

terraform-aws-managed-service-grafana

Terraform module to create AWS Managed Service for Grafana (AMG) resources 🇺🇦
HCL
36
star
41

terraform-aws-batch

Terraform module to create AWS Batch resources 🇺🇦
HCL
35
star
42

terraform-aws-app-runner

Terraform module to create AWS App Runner resources 🇺🇦
HCL
32
star
43

terraform-aws-secrets-manager

Terraform module to create AWS Secrets Manager resources 🇺🇦
HCL
28
star
44

terraform-aws-appconfig

Terraform module to create AWS AppConfig resources 🇺🇦
HCL
27
star
45

terraform-aws-managed-service-prometheus

Terraform module to create AWS Managed Service for Prometheus (AMP) resources 🇺🇦
HCL
26
star
46

terraform-aws-efs

Terraform module to create AWS EFS resources 🇺🇦
HCL
24
star
47

terraform-aws-emr

Terraform module to create AWS EMR resources 🇺🇦
HCL
23
star
48

.github

Meta-GitHub repository for all terraform-aws-modules repositories 🇺🇦
22
star
49

terraform-aws-ssm-parameter

Terraform module to create AWS SSM Parameter resources 🇺🇦
HCL
20
star
50

terraform-aws-s3-object

Terraform module which creates S3 object resources on AWS
HCL
17
star
51

terraform-aws-ebs-optimized

Terraform module to determine if an instance can be flagged for EBS optimization
HCL
17
star
52

terraform-aws-customer-gateway

Terraform module to create AWS Customer Gateway resources 🇺🇦
HCL
17
star
53

terraform-aws-global-accelerator

Terraform module to create AWS Global Accelerator resources 🇺🇦
HCL
16
star
54

terraform-aws-memory-db

Terraform module to create AWS MemoryDB resources 🇺🇦
HCL
16
star
55

terraform-aws-opensearch

Terraform module to create AWS OpenSearch resources 🇺🇦
HCL
15
star
56

terraform-aws-elasticache

Terraform module to create AWS ElastiCache resources 🇺🇦
HCL
12
star
57

terraform-aws-network-firewall

Terraform module to create AWS Network Firewall resources 🇺🇦
HCL
12
star
58

terraform-aws-fsx

Terraform module to create AWS FSx resources 🇺🇦
HCL
4
star
59

atlantis-demo

Demo repository for Atlantis
3
star