NotificationChannel class
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.
Notification Channels are designed to be flexible and are made up of a supported type
and labels to configure that channel. Each type has specific labels that need to be
present for that channel to be correctly configured. The labels that are required to be
present for one channel type are often different than those required for another.
Due to these loose constraints it's often best to set up a channel through the UI
and import it to the provider when setting up a brand new channel type to determine which
labels are required.
A list of supported channels per project the list endpoint can be
accessed programmatically or through the api explorer at https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.notificationChannelDescriptors/list .
This provides the channel type and all of the required labels that must be passed.
To get more information about NotificationChannel, see:
> Note: All arguments marked as write-only values will not be stored in the state: sensitive_labels.auth_token_wo, sensitive_labels.password_wo, sensitive_labels.service_key_wo.
Read more about Write-only Arguments.
Example Usage
Notification Channel Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const basic = new gcp.monitoring.NotificationChannel("basic", {
displayName: "Test Notification Channel",
type: "email",
labels: {
email_address: "fake_email@blahblah.com",
},
forceDelete: false,
});
import pulumi
import pulumi_gcp as gcp
basic = gcp.monitoring.NotificationChannel("basic",
display_name="Test Notification Channel",
type="email",
labels={
"email_address": "fake_email@blahblah.com",
},
force_delete=False)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var basic = new Gcp.Monitoring.NotificationChannel("basic", new()
{
DisplayName = "Test Notification Channel",
Type = "email",
Labels =
{
{ "email_address", "fake_email@blahblah.com" },
},
ForceDelete = false,
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/monitoring"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := monitoring.NewNotificationChannel(ctx, "basic", &monitoring.NotificationChannelArgs{
DisplayName: pulumi.String("Test Notification Channel"),
Type: pulumi.String("email"),
Labels: pulumi.StringMap{
"email_address": pulumi.String("fake_email@blahblah.com"),
},
ForceDelete: pulumi.Bool(false),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_monitoring_notificationchannel" "basic" {
display_name = "Test Notification Channel"
type = "email"
labels = {
"email_address" = "fake_email@blahblah.com"
}
force_delete = false
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.monitoring.NotificationChannel;
import com.pulumi.gcp.monitoring.NotificationChannelArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var basic = new NotificationChannel("basic", NotificationChannelArgs.builder()
.displayName("Test Notification Channel")
.type("email")
.labels(Map.of("email_address", "fake_email@blahblah.com"))
.forceDelete(false)
.build());
}
}
resources:
basic:
type: gcp:monitoring:NotificationChannel
properties:
displayName: Test Notification Channel
type: email
labels:
email_address: fake_email@blahblah.com
forceDelete: false
Notification Channel Sensitive
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.monitoring.NotificationChannel("default", {
displayName: "Test Slack Channel",
type: "slack",
labels: {
channel_name: "#foobar",
},
sensitiveLabels: {
authToken: "one",
},
});
import pulumi
import pulumi_gcp as gcp
default = gcp.monitoring.NotificationChannel("default",
display_name="Test Slack Channel",
type="slack",
labels={
"channel_name": "#foobar",
},
sensitive_labels={
"auth_token": "one",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var @default = new Gcp.Monitoring.NotificationChannel("default", new()
{
DisplayName = "Test Slack Channel",
Type = "slack",
Labels =
{
{ "channel_name", "#foobar" },
},
SensitiveLabels = new Gcp.Monitoring.Inputs.NotificationChannelSensitiveLabelsArgs
{
AuthToken = "one",
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/monitoring"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := monitoring.NewNotificationChannel(ctx, "default", &monitoring.NotificationChannelArgs{
DisplayName: pulumi.String("Test Slack Channel"),
Type: pulumi.String("slack"),
Labels: pulumi.StringMap{
"channel_name": pulumi.String("#foobar"),
},
SensitiveLabels: &monitoring.NotificationChannelSensitiveLabelsArgs{
AuthToken: pulumi.String("one"),
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_monitoring_notificationchannel" "default" {
display_name = "Test Slack Channel"
type = "slack"
labels = {
"channel_name" = "#foobar"
}
sensitive_labels = {
auth_token = "one"
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.monitoring.NotificationChannel;
import com.pulumi.gcp.monitoring.NotificationChannelArgs;
import com.pulumi.gcp.monitoring.inputs.NotificationChannelSensitiveLabelsArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var default_ = new NotificationChannel("default", NotificationChannelArgs.builder()
.displayName("Test Slack Channel")
.type("slack")
.labels(Map.of("channel_name", "#foobar"))
.sensitiveLabels(NotificationChannelSensitiveLabelsArgs.builder()
.authToken("one")
.build())
.build());
}
}
resources:
default:
type: gcp:monitoring:NotificationChannel
properties:
displayName: Test Slack Channel
type: slack
labels:
channel_name: '#foobar'
sensitiveLabels:
authToken: one
Import
NotificationChannel can be imported using any of these accepted formats:
{{name}}
When using the pulumi import command, NotificationChannel can be imported using one of the formats above. For example:
$ pulumi import gcp:monitoring/notificationChannel:NotificationChannel default {{name}}
Constructors
- NotificationChannel(String name, {NotificationChannelArgs? args, CustomResourceOptions? options})
-
Creates a new NotificationChannel.
nameThe Pulumi resource name.argsArguments used to configure this NotificationChannel. The set of arguments for NotificationChannel.optionsResource options controlling this resource's behavior. - NotificationChannel.reference(String urn)
- Creates a typed reference to an existing NotificationChannel resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
description
↔ Output<
String?> -
An optional human-readable description of this notification channel. This description may provide additional details, beyond the display name, for the channel. This may not exceed 1024 Unicode characters.
latefinal
-
displayName
↔ Output<
String?> -
An optional human-readable name for this notification channel. It is recommended that you specify a non-empty and unique name in order to make it easier to identify the channels in your project, though this is not enforced. The display name is limited to 512 Unicode characters.
latefinal
-
enabled
↔ Output<
bool?> -
Whether notifications are forwarded to the described channel. This makes it possible to disable delivery of notifications to a particular channel without removing the channel from all alerting policies that reference the channel. This is a more convenient approach when the change is temporary and you want to receive notifications from the same set of alerting policies on the channel at some point in the future.
latefinal
-
forceDelete
↔ Output<
bool?> -
If true, the notification channel will be deleted regardless
of its use in alert policies (the policies will be updated
to remove the channel). If false, channels that are still
referenced by an existing alerting policy will fail to be
deleted in a delete operation.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
labels
↔ Output<
Map< String, String> ?> -
Configuration fields that define the channel and its behavior. The
permissible and required labels are specified in the
NotificationChannelDescriptor corresponding to the type field.
Labels with sensitive data are obfuscated by the API and therefore the provider cannot
determine if there are upstream changes to these fields. They can also be configured via
the sensitiveLabels block, but cannot be configured in both places.
latefinal
-
name
↔ Output<
String> -
The full REST resource name for this channel. The syntax is:
projects/
PROJECT_ID/notificationChannels/CHANNEL_IDTheCHANNEL_IDis automatically assigned by the server on creation.latefinal -
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sensitiveLabels
↔ Output<
NotificationChannelSensitiveLabels?> -
Different notification type behaviors are configured primarily using the the
labelsfield on this resource. This block contains the labels which contain secrets or passwords so that they can be marked sensitive and hidden from plan output. The name of the field, eg: password, will be the key in thelabelsmap in the api request. Credentials may not be specified in both locations and will cause an error. Changing from one location to a different credential configuration in the config will require an apply to update state. Structure is documented below.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
type
↔ Output<
String> -
The type of the notification channel. This field matches the value of the NotificationChannelDescriptor.type field. See https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.notificationChannelDescriptors/list to get the list of valid values such as "email", "slack", etc...
latefinal
-
urn
↔ Output<
String> -
latefinalinherited
-
userLabels
↔ Output<
Map< String, String> ?> -
User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field. This field is intended to be used for organizing and identifying the NotificationChannel objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.
latefinal
-
verificationStatus
↔ Output<
String> -
Indicates whether this channel has been verified or not. On a ListNotificationChannels or GetNotificationChannel operation, this field is expected to be populated.If the value is UNVERIFIED, then it indicates that the channel is non-functioning (it both requires verification and lacks verification); otherwise, it is assumed that the channel works.If the channel is neither VERIFIED nor UNVERIFIED, it implies that the channel is of a type that does not require verification or that this specific channel has been exempted from verification because it was created prior to verification being required for channels of this type.This field cannot be modified using a standard UpdateNotificationChannel operation. To change the value of this field, you must call VerifyNotificationChannel.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {NotificationChannelState? state, CustomResourceOptions? options}) → NotificationChannel -
Gets an existing NotificationChannel resource's state with the given
nameandid.