Benachrichtigungskanäle mit Terraform erstellen und verwalten
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
In diesem Dokument wird beschrieben, wie Sie mit demGoogle Cloud Terraform-Provider Benachrichtigungschannels in Ihrem Google Cloud -Projekt erstellen. Der Google Cloud Terraform-Provider bietet die folgenden Ressourcen für Benachrichtigungsrichtlinien und ‑kanäle:
Terraform ist ein Tool zum Erstellen, Ändern und zur Versionsverwaltung von Infrastruktur. Terraform verwendet Konfigurationsdateien, um die Komponenten zu beschreiben, die zum Ausführen einer einzelnen Anwendung oder Ihrer gesamten Infrastruktur erforderlich sind.
Weitere Informationen zur Verwendung von Terraform finden Sie unter:
Bitten Sie Ihren Administrator, Ihnen die IAM-Rolle Notification Channel Editor (roles/monitoring.notificationChannelEditor) für Ihr Projekt zuzuweisen, damit Sie die Berechtigungen erhalten, die Sie zum Erstellen und Ändern von Benachrichtigungschannels mit Terraform benötigen.
Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff auf Projekte, Ordner und Organisationen verwalten.
Wechseln Sie in Cloud Shell zu dem Verzeichnis, das Ihre Terraform-Konfiguration enthält.
Bearbeiten Sie die Konfigurationsdatei, suchen Sie nach der google_monitoring_notification_channel-Ressource für Ihren Benachrichtigungschannel und ändern oder löschen Sie diese Ressource.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[],[],null,["# Create and manage notification channels with Terraform\n\nThis document describes how to use the\nGoogle Cloud Terraform Provider to create\nnotification channels in your Google Cloud project. The Google Cloud Terraform Provider\noffers the following resources for alerting policies and notification channels:\n\n- [google_monitoring_alert_policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_alert_policy)\n- [google_monitoring_notification_channel](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_notification_channel)\n\n[Terraform](https://www.terraform.io/) is a tool for building,\nchanging, and versioning infrastructure. It uses configuration files to describe\nthe components needed to run a single application or your entire infrastructure.\nFor more information about using Terraform, see the following:\n\n- [Terraform on Google Cloud documentation](/docs/terraform#docs)\n- [Google Cloud Terraform Provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs)\n- [Get Started - Google Cloud](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started)\n\nBefore you begin\n----------------\n\n\nTo get the permissions that\nyou need to create and modify notification channels by using Terraform,\n\nask your administrator to grant you the\n\n\n[Notification Channel Editor](/iam/docs/roles-permissions/monitoring#monitoring.notificationChannelEditor) (`roles/monitoring.notificationChannelEditor`)\nIAM role on your project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nFor more information about Cloud Monitoring roles,\nsee [Control access with Identity and Access Management](/monitoring/access-control).\n\nCreate a notification channel\n-----------------------------\n\nTo create a notification channel in your Google Cloud project, do the following:\n\n1. [Install and configure Terraform](/docs/terraform/install-configure-terraform).\n\n2. In the Cloud Shell,\n go to the directory that contains your Terraform configuration.\n\n3. Edit the configuration file and add your notification channel.\n\n For example, the following configuration defines an email\n notification channel: \n\n resource \"google_monitoring_notification_channel\" \"email\" {\n display_name = \"Tier 1 Support Email\"\n type = \"email\"\n labels = {\n email_address = \"\u003cvar translate=\"no\"\u003eUSER_EMAIL\u003c/var\u003e\"\n }\n }\n\n4. In the Cloud Shell, enter `terraform apply`.\n\nEdit or delete notification channels\n------------------------------------\n\nTo edit or delete a notification channel in your Google Cloud project, do the\nfollowing:\n\n1. [Install and configure Terraform](/docs/terraform/install-configure-terraform).\n\n2. In the Cloud Shell,\n go to the directory that contains your Terraform configuration.\n\n3. Edit your configuration file, find the\n `google_monitoring_notification_channel`\n resource for your notification channel, and then modify or delete that\n resource.\n\n4. In the Cloud Shell, enter `terraform apply`.\n\nWhat's next\n-----------\n\n- [Create alerting policies with Terraform](/monitoring/alerts/terraform).\n- Learn more about [Terraform](https://www.terraform.io/).\n- Try out code samples that use the Google Cloud Terraform Provider with Cloud Monitoring.\n- View the Google Cloud Terraform Provider [repository on GitHub](https://github.com/hashicorp/terraform-provider-google).\n- [File a GitHub issue](https://github.com/hashicorp/terraform-provider-google/issues) to report a bug or ask a question about Terraform."]]