This document describes how to use the Google Cloud Terraform Provider to create notification channels in your Google Cloud project. The Google Cloud Terraform Provider offers the following resources for alerting policies and notification channels:
Terraform is a tool for building, changing, and versioning infrastructure. It uses configuration files to describe the components needed to run a single application or your entire infrastructure. For more information about using Terraform, see the following:
Before you begin
To get the permissions that you need to create and modify notification channels by using Terraform,
ask your administrator to grant you the
Notification Channel Editor (roles/monitoring.notificationChannelEditor
) IAM role on your project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
For more information about Cloud Monitoring roles, see Control access with Identity and Access Management.
Create a notification channel
To create a notification channel in your Google Cloud project, do the following:
Ensure that Terraform is installed in the Cloud Shell.
In the Cloud Shell, go to the directory that contains your Terraform configuration.
Edit the configuration file and add your notification channel.
For example, the following configuration defines an email notification channel:
resource "google_monitoring_notification_channel" "email" { display_name = "Tier 1 Support Email" type = "email" labels = { email_address = "USER_EMAIL" } }
In the Cloud Shell, enter
terraform apply
.
Edit or delete notification channels
To edit or delete a notification channel in your Google Cloud project, do the following:
Ensure that Terraform is installed in the Cloud Shell.
In the Cloud Shell, go to the directory that contains your Terraform configuration.
Edit your configuration file, find the
google_monitoring_notification_channel
resource for your notification channel, and then modify or delete that resource.In the Cloud Shell, enter
terraform apply
.
What's next
- Create alerting policies with Terraform.
- Learn more about Terraform.
- Try out code samples that use the Google Cloud Terraform Provider with Cloud Monitoring.
- View the Google Cloud Terraform Provider repository on GitHub.
- File a GitHub issue to report a bug or ask a question about Terraform.