Google Cloud (GCP) Classic

Pulumi Official
Package maintained by Pulumi
v6.24.0 published on Tuesday, May 17, 2022 by Pulumi

getNotificationChannel

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. Fields containing sensitive information like authentication tokens or contact info are only partially populated on retrieval.

To get more information about NotificationChannel, see:

Example Usage

Notification Channel Basic

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var basic = Output.Create(Gcp.Monitoring.GetNotificationChannel.InvokeAsync(new Gcp.Monitoring.GetNotificationChannelArgs
        {
            DisplayName = "Test Notification Channel",
        }));
        var alertPolicy = new Gcp.Monitoring.AlertPolicy("alertPolicy", new Gcp.Monitoring.AlertPolicyArgs
        {
            DisplayName = "My Alert Policy",
            NotificationChannels = 
            {
                basic.Apply(basic => basic.Name),
            },
            Combiner = "OR",
            Conditions = 
            {
                new Gcp.Monitoring.Inputs.AlertPolicyConditionArgs
                {
                    DisplayName = "test condition",
                    ConditionThreshold = new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdArgs
                    {
                        Filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
                        Duration = "60s",
                        Comparison = "COMPARISON_GT",
                        Aggregations = 
                        {
                            new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdAggregationArgs
                            {
                                AlignmentPeriod = "60s",
                                PerSeriesAligner = "ALIGN_RATE",
                            },
                        },
                    },
                },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/monitoring"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		basic, err := monitoring.LookupNotificationChannel(ctx, &monitoring.LookupNotificationChannelArgs{
			DisplayName: pulumi.StringRef("Test Notification Channel"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = monitoring.NewAlertPolicy(ctx, "alertPolicy", &monitoring.AlertPolicyArgs{
			DisplayName: pulumi.String("My Alert Policy"),
			NotificationChannels: pulumi.StringArray{
				pulumi.String(basic.Name),
			},
			Combiner: pulumi.String("OR"),
			Conditions: monitoring.AlertPolicyConditionArray{
				&monitoring.AlertPolicyConditionArgs{
					DisplayName: pulumi.String("test condition"),
					ConditionThreshold: &monitoring.AlertPolicyConditionConditionThresholdArgs{
						Filter:     pulumi.String("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\""),
						Duration:   pulumi.String("60s"),
						Comparison: pulumi.String("COMPARISON_GT"),
						Aggregations: monitoring.AlertPolicyConditionConditionThresholdAggregationArray{
							&monitoring.AlertPolicyConditionConditionThresholdAggregationArgs{
								AlignmentPeriod:  pulumi.String("60s"),
								PerSeriesAligner: pulumi.String("ALIGN_RATE"),
							},
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var basic = Output.of(MonitoringFunctions.getNotificationChannel(GetNotificationChannelArgs.builder()
            .displayName("Test Notification Channel")
            .build()));

        var alertPolicy = new AlertPolicy("alertPolicy", AlertPolicyArgs.builder()        
            .displayName("My Alert Policy")
            .notificationChannels(basic.apply(getNotificationChannelResult -> getNotificationChannelResult.getName()))
            .combiner("OR")
            .conditions(AlertPolicyCondition.builder()
                .displayName("test condition")
                .conditionThreshold(AlertPolicyConditionConditionThreshold.builder()
                    .filter("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"")
                    .duration("60s")
                    .comparison("COMPARISON_GT")
                    .aggregations(AlertPolicyConditionConditionThresholdAggregation.builder()
                        .alignmentPeriod("60s")
                        .perSeriesAligner("ALIGN_RATE")
                        .build())
                    .build())
                .build())
            .build());

        }
}
import pulumi
import pulumi_gcp as gcp

basic = gcp.monitoring.get_notification_channel(display_name="Test Notification Channel")
alert_policy = gcp.monitoring.AlertPolicy("alertPolicy",
    display_name="My Alert Policy",
    notification_channels=[basic.name],
    combiner="OR",
    conditions=[gcp.monitoring.AlertPolicyConditionArgs(
        display_name="test condition",
        condition_threshold=gcp.monitoring.AlertPolicyConditionConditionThresholdArgs(
            filter="metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
            duration="60s",
            comparison="COMPARISON_GT",
            aggregations=[gcp.monitoring.AlertPolicyConditionConditionThresholdAggregationArgs(
                alignment_period="60s",
                per_series_aligner="ALIGN_RATE",
            )],
        ),
    )])
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const basic = gcp.monitoring.getNotificationChannel({
    displayName: "Test Notification Channel",
});
const alertPolicy = new gcp.monitoring.AlertPolicy("alertPolicy", {
    displayName: "My Alert Policy",
    notificationChannels: [basic.then(basic => basic.name)],
    combiner: "OR",
    conditions: [{
        displayName: "test condition",
        conditionThreshold: {
            filter: "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
            duration: "60s",
            comparison: "COMPARISON_GT",
            aggregations: [{
                alignmentPeriod: "60s",
                perSeriesAligner: "ALIGN_RATE",
            }],
        },
    }],
});
resources:
  alertPolicy:
    type: gcp:monitoring:AlertPolicy
    properties:
      displayName: My Alert Policy
      notificationChannels:
        - ${basic.name}
      combiner: OR
      conditions:
        - displayName: test condition
          conditionThreshold:
            filter: metric.type="compute.googleapis.com/instance/disk/write_bytes_count" AND resource.type="gce_instance"
            duration: 60s
            comparison: COMPARISON_GT
            aggregations:
              - alignmentPeriod: 60s
                perSeriesAligner: ALIGN_RATE
variables:
  basic:
    Fn::Invoke:
      Function: gcp:monitoring:getNotificationChannel
      Arguments:
        displayName: Test Notification Channel

Using getNotificationChannel

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getNotificationChannel(args: GetNotificationChannelArgs, opts?: InvokeOptions): Promise<GetNotificationChannelResult>
function getNotificationChannelOutput(args: GetNotificationChannelOutputArgs, opts?: InvokeOptions): Output<GetNotificationChannelResult>
def get_notification_channel(display_name: Optional[str] = None,
                             labels: Optional[Mapping[str, str]] = None,
                             project: Optional[str] = None,
                             type: Optional[str] = None,
                             user_labels: Optional[Mapping[str, str]] = None,
                             opts: Optional[InvokeOptions] = None) -> GetNotificationChannelResult
def get_notification_channel_output(display_name: Optional[pulumi.Input[str]] = None,
                             labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                             project: Optional[pulumi.Input[str]] = None,
                             type: Optional[pulumi.Input[str]] = None,
                             user_labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                             opts: Optional[InvokeOptions] = None) -> Output[GetNotificationChannelResult]
func LookupNotificationChannel(ctx *Context, args *LookupNotificationChannelArgs, opts ...InvokeOption) (*LookupNotificationChannelResult, error)
func LookupNotificationChannelOutput(ctx *Context, args *LookupNotificationChannelOutputArgs, opts ...InvokeOption) LookupNotificationChannelResultOutput

> Note: This function is named LookupNotificationChannel in the Go SDK.

public static class GetNotificationChannel 
{
    public static Task<GetNotificationChannelResult> InvokeAsync(GetNotificationChannelArgs args, InvokeOptions? opts = null)
    public static Output<GetNotificationChannelResult> Invoke(GetNotificationChannelInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetNotificationChannelResult> getNotificationChannel(GetNotificationChannelArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: gcp:monitoring/getNotificationChannel:getNotificationChannel
  Arguments:
    # Arguments dictionary

The following arguments are supported:

DisplayName string

The display name for this notification channel.

Labels Dictionary<string, string>

Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.

Project string

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

Type string

The type of the notification channel.

UserLabels Dictionary<string, string>

User-provided key-value labels to filter by.

DisplayName string

The display name for this notification channel.

Labels map[string]string

Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.

Project string

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

Type string

The type of the notification channel.

UserLabels map[string]string

User-provided key-value labels to filter by.

displayName String

The display name for this notification channel.

labels Map

Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.

project String

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

type String

The type of the notification channel.

userLabels Map

User-provided key-value labels to filter by.

displayName string

The display name for this notification channel.

labels {[key: string]: string}

Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.

project string

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

type string

The type of the notification channel.

userLabels {[key: string]: string}

User-provided key-value labels to filter by.

display_name str

The display name for this notification channel.

labels Mapping[str, str]

Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.

project str

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

type str

The type of the notification channel.

user_labels Mapping[str, str]

User-provided key-value labels to filter by.

displayName String

The display name for this notification channel.

labels Map

Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.

project String

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

type String

The type of the notification channel.

userLabels Map

User-provided key-value labels to filter by.

getNotificationChannel Result

The following output properties are available:

Description string
Enabled bool
Id string

The provider-assigned unique ID for this managed resource.

Name string
SensitiveLabels List<GetNotificationChannelSensitiveLabel>
VerificationStatus string
DisplayName string
Labels Dictionary<string, string>
Project string
Type string
UserLabels Dictionary<string, string>
Description string
Enabled bool
Id string

The provider-assigned unique ID for this managed resource.

Name string
SensitiveLabels []GetNotificationChannelSensitiveLabel
VerificationStatus string
DisplayName string
Labels map[string]string
Project string
Type string
UserLabels map[string]string
description String
enabled Boolean
id String

The provider-assigned unique ID for this managed resource.

name String
sensitiveLabels ListNotificationChannelSensitiveLabel>
verificationStatus String
displayName String
labels Map
project String
type String
userLabels Map
description string
enabled boolean
id string

The provider-assigned unique ID for this managed resource.

name string
sensitiveLabels GetNotificationChannelSensitiveLabel[]
verificationStatus string
displayName string
labels {[key: string]: string}
project string
type string
userLabels {[key: string]: string}
description str
enabled bool
id str

The provider-assigned unique ID for this managed resource.

name str
sensitive_labels Sequence[GetNotificationChannelSensitiveLabel]
verification_status str
display_name str
labels Mapping[str, str]
project str
type str
user_labels Mapping[str, str]
description String
enabled Boolean
id String

The provider-assigned unique ID for this managed resource.

name String
sensitiveLabels List
verificationStatus String
displayName String
labels Map
project String
type String
userLabels Map

Supporting Types

GetNotificationChannelSensitiveLabel

AuthToken string
Password string
ServiceKey string
AuthToken string
Password string
ServiceKey string
authToken String
password String
serviceKey String
authToken string
password string
serviceKey string
authToken String
password String
serviceKey String

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.