Criar e gerenciar canais de notificação com o Terraform
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Neste documento, descrevemos como usar o
provedor do TerraformGoogle Cloud para criar
canais de notificação no projeto Google Cloud . O Google Cloud provedor do Terraform
oferece os seguintes recursos para políticas de alerta e canais de notificação:
O Terraform é uma ferramenta para criar,
alterar e controlar versões de infraestrutura. Ele usa arquivos de configuração para descrever
os componentes necessários para executar um único aplicativo ou toda a infraestrutura.
Para mais informações sobre como usar o Terraform, consulte o seguinte:
Para receber as permissões necessárias para criar e modificar canais de notificação usando o Terraform,
peça ao administrador para conceder a você o papel do IAM
Editor de canais de notificação (roles/monitoring.notificationChannelEditor)
no seu projeto.
Para mais informações sobre a concessão de papéis, consulte Gerenciar o acesso a projetos, pastas e organizações.
No Cloud Shell,
acesse o diretório que contém sua configuração do Terraform.
Edite o arquivo de configuração, encontre o recurso
google_monitoring_notification_channel
do seu canal de notificação e modifique ou exclua esse
recurso.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-28 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."]]