Membuat dan mengelola saluran notifikasi dengan Terraform
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini menjelaskan cara menggunakan
Google Cloud Penyedia Terraform untuk membuat
saluran notifikasi di project Google Cloud Anda. Google Cloud Penyedia Terraform
menawarkan resource berikut untuk kebijakan pemberitahuan dan saluran notifikasi:
Terraform adalah alat untuk membangun, mengubah, dan membuat versi infrastruktur. Terraform menggunakan file konfigurasi untuk menjelaskan
komponen yang diperlukan untuk menjalankan satu aplikasi atau seluruh infrastruktur Anda.
Untuk mengetahui informasi selengkapnya tentang cara menggunakan Terraform, lihat artikel berikut:
Untuk mendapatkan izin yang diperlukan untuk membuat dan mengubah saluran notifikasi menggunakan Terraform, minta administrator untuk memberi Anda peran IAM Notification Channel Editor (roles/monitoring.notificationChannelEditor) di project Anda.
Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.
Di Cloud Shell,
buka direktori yang berisi konfigurasi Terraform Anda.
Edit file konfigurasi Anda, temukan
google_monitoring_notification_channel
resource untuk saluran notifikasi Anda, lalu ubah atau hapus
resource tersebut.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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."]]