Show / Hide Table of Contents

Class Notification

Creates a new notification configuration on a specified bucket, establishing a flow of event notifications from GCS to a Cloud Pub/Sub topic. For more information see the official documentation and API.

In order to enable notifications, a special Google Cloud Storage service account unique to the project must have the IAM permission "projects.topics.publish" for a Cloud Pub/Sub topic in the project. To get the service account's email address, use the gcp.storage.getProjectServiceAccount datasource's email_address value, and see below for an example of enabling notifications by granting the correct IAM permission. See the notifications documentation for more details.

NOTE: This resource can affect your storage IAM policy. If you are using this in the same config as your storage IAM policy resources, consider making this resource dependent on those IAM resources via depends_on. This will safeguard against errors due to IAM race conditions.

Example Usage

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var gcsAccount = Output.Create(Gcp.Storage.GetProjectServiceAccount.InvokeAsync());
    var topic = new Gcp.PubSub.Topic("topic", new Gcp.PubSub.TopicArgs
    {
    });
    var binding = new Gcp.PubSub.TopicIAMBinding("binding", new Gcp.PubSub.TopicIAMBindingArgs
    {
        Topic = topic.Id,
        Role = "roles/pubsub.publisher",
        Members = 
        {
            gcsAccount.Apply(gcsAccount => $"serviceAccount:{gcsAccount.EmailAddress}"),
        },
    });
    // End enabling notifications
    var bucket = new Gcp.Storage.Bucket("bucket", new Gcp.Storage.BucketArgs
    {
    });
    var notification = new Gcp.Storage.Notification("notification", new Gcp.Storage.NotificationArgs
    {
        Bucket = bucket.Name,
        PayloadFormat = "JSON_API_V1",
        Topic = topic.Id,
        EventTypes = 
        {
            "OBJECT_FINALIZE",
            "OBJECT_METADATA_UPDATE",
        },
        CustomAttributes = 
        {
            { "new-attribute", "new-attribute-value" },
        },
    });
    // Enable notifications by giving the correct IAM permission to the unique service account.
}

}
Inheritance
System.Object
Resource
CustomResource
Notification
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Gcp.Storage
Assembly: Pulumi.Gcp.dll
Syntax
public class Notification : CustomResource

Constructors

View Source

Notification(String, NotificationArgs, CustomResourceOptions)

Create a Notification resource with the given unique name, arguments, and options.

Declaration
public Notification(string name, NotificationArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

NotificationArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Bucket

The name of the bucket.

Declaration
public Output<string> Bucket { get; }
Property Value
Type Description
Output<System.String>
View Source

CustomAttributes

A set of key/value attribute pairs to attach to each Cloud PubSub message published for this notification subscription

Declaration
public Output<ImmutableDictionary<string, string>> CustomAttributes { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.String>>
View Source

EventTypes

List of event type filters for this notification config. If not specified, Cloud Storage will send notifications for all event types. The valid types are: &quot;OBJECT_FINALIZE&quot;, &quot;OBJECT_METADATA_UPDATE&quot;, &quot;OBJECT_DELETE&quot;, &quot;OBJECT_ARCHIVE&quot;

Declaration
public Output<ImmutableArray<string>> EventTypes { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

NotificationId

The ID of the created notification.

Declaration
public Output<string> NotificationId { get; }
Property Value
Type Description
Output<System.String>
View Source

ObjectNamePrefix

Specifies a prefix path filter for this notification config. Cloud Storage will only send notifications for objects in this bucket whose names begin with the specified prefix.

Declaration
public Output<string> ObjectNamePrefix { get; }
Property Value
Type Description
Output<System.String>
View Source

PayloadFormat

The desired content of the Payload. One of &quot;JSON_API_V1&quot; or &quot;NONE&quot;.

Declaration
public Output<string> PayloadFormat { get; }
Property Value
Type Description
Output<System.String>
View Source

SelfLink

The URI of the created resource.

Declaration
public Output<string> SelfLink { get; }
Property Value
Type Description
Output<System.String>
View Source

Topic

The Cloud PubSub topic to which this subscription publishes. Expects either the topic name, assumed to belong to the default GCP provider project, or the project-level name, i.e. projects/my-gcp-project/topics/my-topic or my-topic. If the project is not set in the provider, you will need to use the project-level name.

Declaration
public Output<string> Topic { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, NotificationState, CustomResourceOptions)

Get an existing Notification resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static Notification Get(string name, Input<string> id, NotificationState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

NotificationState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Notification
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.