terraform-aws-modules CloudWatch

repository·master·Indexed 41 days ago

https://github.com/terraform-aws-modules/terraform-aws-cloudwatch

A comprehensive Terraform module for managing AWS CloudWatch resources, including Log Groups, Metric Alarms, Metric Streams, Composite Alarms, and Data Protection Policies. It provides automated configurations for CIS AWS Foundations Controls, log anomaly detection, and streaming metrics to Kinesis Firehose and S3.

Tokens
26.3K
Snippets
61
Records
130
Agent score
51%

What's inside terraform-aws-cloudwatch

  1. Configure CloudWatch Log Data Protection Policy

    master

    This module allows you to manage AWS CloudWatch Log Data Protection Policies. These policies help identify and mask sensitive data (such as PII) within your CloudWatch Logs.

    It can manage both the policy document (via a data source) and the actual policy resource attached to a log group. You can configure destinations for findings, such as S3, Kinesis Firehose, or another CloudWatch Log Group.

  2. What is the composite-alarm wrapper module?

    master
    The wrappers/composite-alarm directory provides a module wrapper implementation of the single module wrapper pattern. This pattern is designed for scenarios where using native Terraform for_each is not feasible, such as when using Terragrunt. It allows you to manage multiple instances of a composite alarm within a single configuration file without duplicating files for every resource.
  3. What is the log-account-policy wrapper module?

    master
    The log-account-policy wrapper is a pattern used to manage multiple instances of the modules/log-account-policy module within a single configuration block. This is particularly useful in environments like Terragrunt where native Terraform for_each logic might not be feasible for managing multiple resource copies, allowing you to manage several resources without duplicating configuration files.
  4. Use the log-stream module wrapper for multiple resources

    master

    The wrappers/log-stream directory provides a module wrapper pattern designed for scenarios where native Terraform for_each is not feasible, such as when using Terragrunt. This wrapper allows you to manage multiple instances of the modules/log-stream module within a single configuration block by defining a map of items.

    This wrapper does not add new functionality; it simply facilitates bulk management of the underlying log-stream module resources using two primary input blocks:

    1. defaults: A map of arguments applied to every item in the items block.
    2. items: A map where each key represents a unique instance, and the value is a map of arguments specific to that instance (which can override or supplement defaults).
    # Conceptual structure
    inputs = {
      defaults = {
        # Shared arguments for all log streams
      }
      items = {
        instance_one = {
          # Specific arguments for instance_one
        }
        instance_two = {
          # Specific arguments for instance_two
        }
      }
    }
  5. Use the metric-stream module wrapper

    master

    The wrappers/metric-stream directory provides a module wrapper pattern designed for scenarios where native Terraform for_each is not feasible, such as when using Terragrunt. This wrapper allows you to manage multiple instances of the modules/metric-stream module within a single configuration file by defining a map of items and a set of default values.

    This wrapper does not add new functionality; it only provides a mechanism to iterate over multiple configurations using a defaults block and an items block.

    # Conceptual structure
    inputs = {
      defaults = {
        # Common arguments for all items
      }
      items = {
        item_one = {
          # Specific arguments for item_one
        }
        item_two = {
          # Specific arguments for item_two
        }
      }
    }
  6. Use the metric-alarm wrapper for multiple resources

    master

    The wrappers/metric-alarm module implements a single module wrapper pattern. This allows you to manage multiple instances of the modules/metric-alarm module within a single configuration block. This is particularly useful in environments like Terragrunt where native Terraform for_each might not be feasible, or when you want to manage multiple resources without duplicating configuration files.

    The wrapper accepts two primary configuration blocks:

    1. defaults: A map of arguments applied to every item in the items collection.
    2. items: A map where each key represents a unique instance of the module, and the value is a map of arguments specific to that instance. Any argument supported by the underlying modules/metric-alarm module can be used here.
  7. Understand anomaly_visibility_time behavior

    master

    The anomaly_visibility_time setting determines how long an anomaly remains flagged before being treated as normal behavior.

    If an anomaly is not corrected within the specified time period (between 7 and 90 days), the detector will automatically baseline it. Once baselined, new occurrences of that same pattern will be treated as normal and will no longer trigger anomaly detections. It is critical to resolve the underlying cause of an anomaly before this period elapses.

  8. How the metric-alarms-by-multiple-dimensions wrapper works

    master

    This wrapper implements a single module wrapper pattern designed for scenarios where native Terraform for_each is not feasible, such as when using Terragrunt. It allows you to manage multiple instances of the metric-alarms-by-multiple-dimensions module within a single configuration block or Terragrunt file, preventing the need to duplicate terragrunt.hcl files for every individual resource.

    Note that this wrapper does not add any new functionality; it simply provides a way to pass a map of items to the underlying module to facilitate bulk management.

  9. Use the log-group module wrapper for multiple resources

    master

    The wrappers/log-group directory provides a pattern for managing multiple instances of the modules/log-group module within a single configuration block. This is particularly useful in environments like Terragrunt where native Terraform for_each logic might not be feasible for managing multiple distinct resource copies without duplicating configuration files.

    This wrapper does not add new functionality; it simply maps a map of items to individual module calls. It uses two primary input blocks:

    1. defaults: A map of arguments applied to every item in the items block.
    2. items: A map where each key represents a unique instance of a log group, and the value is a map of arguments specific to that instance. Arguments in items can override or supplement those in defaults (depending on the underlying module implementation).
    module "wrapper" {
      source = "terraform-aws-modules/cloudwatch/aws//wrappers/log-group"
    
      defaults = {
        create = true
        tags = {
          Terraform   = "true"
          Environment = "dev"
        }
      }
    
      items = {
        my-item = {
          # arguments for the first log group
        }
        my-second-item = {
          # arguments for the second log group
        }
      }
    }
  10. Use the log-anomaly-detector module wrapper

    master

    The log-anomaly-detector wrapper is a pattern used to manage multiple instances of the modules/log-anomaly-detector module within a single configuration block. This is particularly useful in environments like Terragrunt where native Terraform for_each might not be feasible, allowing you to manage several resources without duplicating configuration files.

    The wrapper accepts two primary input maps:

    1. defaults: A map of configuration arguments applied to every instance created.
    2. items: A map where each key represents a unique instance, and the value is a map of arguments specific to that instance. These arguments can be any valid argument supported by the underlying modules/log-anomaly-detector module.
    # Conceptual structure
    inputs = {
      defaults = {
        create = true
        tags = { Environment = "dev" }
      }
    
      items = {
        instance_one = {
          # specific arguments for instance_one
        }
        instance_two = {
          # specific arguments for instance_two
        }
      }
    }