Skip to content

mineiros-io/terraform-google-monitoring-notification-channel

Repository files navigation

Build Status GitHub tag (latest SemVer) Terraform Version Google Provider Version Join Slack

terraform-google-monitoring-notification-channel

A Terraform module to manage notification channels on Google Cloud Platform (GCP).

A NotificationChannel is a medium through which an alert is delivered when a policy violation is detected. Examples of channels include email, SMS, and third-party messaging applications.

This module supports Terraform version 1 and is compatible with the Terraform Google Cloud Provider version 4. and 5._**

This module is part of our Infrastructure as Code (IaC) framework that enables our users and customers to easily deploy and manage reusable, secure, and production-grade cloud infrastructure.

Module Features

This module implements the following Terraform resources

  • google_monitoring_notification_channel

Getting Started

Create a slack notification channel:

module "terraform-google-monitoring-notification-channel" {
  source  = "mineiros-io/monitoring-notification-channel/google"
  version = "0.0.3"

  type        = "slack"

  display_name = "slack-alert"
  description  = "An example Slack notification channel."

  labels       = {
    channel_name = "#alerts"
  }

  sensitive_labels = {
    auth_token = "XXX"
  }

Module Argument Reference

See variables.tf and examples/ for details and use-cases.

Top-level Arguments

Main Resource Configuration

  • type: (Required string)

    The type of the notification channel. Valid values are email, slack, sms, webhook_basicauth and pagerduty.

  • project: (Optional string)

    The ID of the project in which the resource belongs. If it is not set, the provider project is used.

    Default is null.

  • display_name: (Optional string)

    An human-readable name for this notification channel. It is recommended that you specify a non-empty and unique name in order to make it easier to identify the channels in your project, though this is not enforced. The display name is limited to 512 Unicode characters.

    Default is null.

  • description: (Optional string)

    An optional human-readable description of this notification channel. This description may provide additional details, beyond the display name, for the channel. This may not exceed 1024 Unicode characters.

    Default is "Notification managed by the mineiros-io/terraform-google-monitoring-notification-channel Terraform module.".

  • enabled: (Optional bool)

    Whether notifications are forwarded to the described channel. This makes it possible to disable delivery of notifications to a particular channel without removing the channel from all alerting policies that reference the channel. This is a more convenient approach when the change is temporary and you want to receive notifications from the same set of alerting policies on the channel at some point in the future.

    Default is true.

  • labels: (Optional map(string))

    Configuration fields that define the channel and its behavior. Labels with sensitive data should be configured via the 'sensitive_labels' block.

    Default is {}.

    Example:

    labels = {
      email_address = "address@example.com"
    }
  • user_labels: (Optional map(string))

    User-supplied key/value data that does not need to conform to the corresponding notification channel schema, unlike the labels field. The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.

    Default is {}.

  • sensitive_labels: (Optional any)

    Different notification type behaviors are configured primarily using the the labels field on this resource. This block contains the labels which contain secrets or passwords so that they can be marked sensitive and hidden from plan output. The name of the field, eg: password, will be the key in the labels map in the api request. Credentials may not be specified in both locations and will cause an error. Changing from one location to a different credential configuration in the config will require an apply to update state.

    Default is null.

    Example:

    sensitive_labels = {
      auth_token = "example-token"
    }

    The object accepts the following attributes:

    • auth_token: (Optional string)

      An authorization token for a notification channel. Channel types that support this field include: slack Note: This property is sensitive and will not be displayed in the plan.

    • password: (Optional string)

      An password for a notification channel. Channel types that support this field include: webhook_basicauth Note: This property is sensitive and will not be displayed in the plan.

    • service_key: (Optional string)

      An servicekey token for a notification channel. Channel types that support this field include: pagerduty Note: This property is sensitive and will not be displayed in the plan.

Module Configuration

  • module_enabled: (Optional bool)

    Specifies whether resources in the module will be created.

    Default is true.

  • module_timeouts: (Optional any)

    How long certain operations (per resource type) are allowed to take before being considered to have failed.

    Default is {}.

    Example:

    module_timeouts = {
      google_monitoring_notification_channel = {
        create = "4m"
        update = "4m"
        delete = "4m"
      }
    }

    The object accepts the following attributes:

    • google_monitoring_notification_channel: (Optional any)

      Timeout for the google_monitoring_notification_channel resource.

      The object accepts the following attributes:

      • create: (Optional string)

        Timeout for create operations.

      • update: (Optional string)

        Timeout for update operations.

      • delete: (Optional string)

        Timeout for delete operations.

  • module_depends_on: (Optional any)

    A list of dependencies. Any object can be assigned to this list to define a hidden external dependency.

    Example:

    module_depends_on = [
      google_monitoring_alert_policy.alert-policy 
    ]

Module Attributes Reference

The following attributes are exported in the outputs of the module:

  • module_enabled

    Whether this module is enabled.

Module Outputs

The following attributes are exported in the outputs of the module:

  • module_enabled: (bool)

    Whether this module is enabled.

  • notification_channel: (object(notification_channel))

    All attributes of the created google_monitoring_notification_channel resource.

External Documentation

GCP Billing Budgets Documentation

Terraform GCP Provider Documentation

Module Versioning

This Module follows the principles of Semantic Versioning (SemVer).

Given a version number MAJOR.MINOR.PATCH, we increment the:

  1. MAJOR version when we make incompatible changes,
  2. MINOR version when we add functionality in a backwards compatible manner, and
  3. PATCH version when we make backwards compatible bug fixes.

Backwards compatibility in 0.0.z and 0.y.z version

  • Backwards compatibility in versions 0.0.z is not guaranteed when z is increased. (Initial development)
  • Backwards compatibility in versions 0.y.z is not guaranteed when y is increased. (Pre-release)

About Mineiros

Mineiros is a remote-first company headquartered in Berlin, Germany that solves development, automation and security challenges in cloud infrastructure.

Our vision is to massively reduce time and overhead for teams to manage and deploy production-grade and secure cloud infrastructure.

We offer commercial support for all of our modules and encourage you to reach out if you have any questions or need help. Feel free to email us at hello@mineiros.io or join our Community Slack channel.

Reporting Issues

We use GitHub Issues to track community reported issues and missing features.

Contributing

Contributions are always encouraged and welcome! For the process of accepting changes, we use Pull Requests. If you'd like more information, please see our Contribution Guidelines.

Makefile Targets

This repository comes with a handy Makefile. Run make help to see details on each available target.

License

license

This module is licensed under the Apache License Version 2.0, January 2004. Please see LICENSE for full details.

Copyright © 2020-2022 Mineiros GmbH