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.
}
}
Inherited Members
Namespace: Pulumi.Gcp.Storage
Assembly: Pulumi.Gcp.dll
Syntax
public class Notification : CustomResource
Constructors
View SourceNotification(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 SourceBucket
The name of the bucket.
Declaration
public Output<string> Bucket { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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>> |
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: "OBJECT_FINALIZE", "OBJECT_METADATA_UPDATE", "OBJECT_DELETE", "OBJECT_ARCHIVE"
Declaration
public Output<ImmutableArray<string>> EventTypes { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
NotificationId
The ID of the created notification.
Declaration
public Output<string> NotificationId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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> |
PayloadFormat
The desired content of the Payload. One of "JSON_API_V1" or "NONE".
Declaration
public Output<string> PayloadFormat { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
SelfLink
The URI of the created resource.
Declaration
public Output<string> SelfLink { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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 SourceGet(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 |