@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
211 lines (210 loc) • 9.39 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
/**
* 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](https://cloud.google.com/storage/docs/pubsub-notifications)
* and
* [API](https://cloud.google.com/storage/docs/json_api/v1/notifications).
*
* In order to enable notifications, a special Google Cloud Storage service account unique to the project
* must exist and have the IAM permission "projects.topics.publish" for a Cloud Pub/Sub topic in the project.
* This service account is not created automatically when a project is created.
* To ensure the service account exists and obtain its email address for use in granting the correct IAM permission, use the
* [`gcp.storage.getProjectServiceAccount`](https://www.terraform.io/docs/providers/google/d/storage_project_service_account.html)
* datasource's `emailAddress` value, and see below for an example of enabling notifications by granting the correct IAM permission.
* See [the notifications documentation](https://cloud.google.com/storage/docs/gsutil/commands/notification) 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 `dependsOn`. This will safeguard against errors due to IAM race conditions.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // Enable notifications by giving the correct IAM permission to the unique service account.
* const gcsAccount = gcp.storage.getProjectServiceAccount({});
* const topic = new gcp.pubsub.Topic("topic", {name: "default_topic"});
* const binding = new gcp.pubsub.TopicIAMBinding("binding", {
* topic: topic.id,
* role: "roles/pubsub.publisher",
* members: [gcsAccount.then(gcsAccount => `serviceAccount:${gcsAccount.emailAddress}`)],
* });
* // End enabling notifications
* const bucket = new gcp.storage.Bucket("bucket", {
* name: "default_bucket",
* location: "US",
* });
* const notification = new gcp.storage.Notification("notification", {
* bucket: bucket.name,
* payloadFormat: "JSON_API_V1",
* topic: topic.id,
* eventTypes: [
* "OBJECT_FINALIZE",
* "OBJECT_METADATA_UPDATE",
* ],
* customAttributes: {
* "new-attribute": "new-attribute-value",
* },
* }, {
* dependsOn: [binding],
* });
* ```
*
* ## Import
*
* Storage notifications can be imported using any of these accepted formats:
*
* * `{{bucket_name}}/notificationConfigs/{{id}}`
*
* When using the `pulumi import` command, Storage notifications can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:storage/notification:Notification default {{bucket_name}}/notificationConfigs/{{id}}
* ```
*/
export declare class Notification extends pulumi.CustomResource {
/**
* Get an existing Notification resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: NotificationState, opts?: pulumi.CustomResourceOptions): Notification;
/**
* Returns true if the given object is an instance of Notification. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is Notification;
/**
* The name of the bucket.
*/
readonly bucket: pulumi.Output<string>;
/**
* A set of key/value attribute pairs to attach to each Cloud PubSub message published for this notification subscription
*/
readonly customAttributes: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* 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"`
*/
readonly eventTypes: pulumi.Output<string[] | undefined>;
/**
* The ID of the created notification.
*/
readonly notificationId: pulumi.Output<string>;
/**
* 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.
*/
readonly objectNamePrefix: pulumi.Output<string | undefined>;
/**
* The desired content of the Payload. One of `"JSON_API_V1"` or `"NONE"`.
*/
readonly payloadFormat: pulumi.Output<string>;
/**
* The URI of the created resource.
*/
readonly selfLink: pulumi.Output<string>;
/**
* 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.
*
* - - -
*/
readonly topic: pulumi.Output<string>;
/**
* Create a Notification resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: NotificationArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Notification resources.
*/
export interface NotificationState {
/**
* The name of the bucket.
*/
bucket?: pulumi.Input<string>;
/**
* A set of key/value attribute pairs to attach to each Cloud PubSub message published for this notification subscription
*/
customAttributes?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* 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"`
*/
eventTypes?: pulumi.Input<pulumi.Input<string>[]>;
/**
* The ID of the created notification.
*/
notificationId?: pulumi.Input<string>;
/**
* 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.
*/
objectNamePrefix?: pulumi.Input<string>;
/**
* The desired content of the Payload. One of `"JSON_API_V1"` or `"NONE"`.
*/
payloadFormat?: pulumi.Input<string>;
/**
* The URI of the created resource.
*/
selfLink?: pulumi.Input<string>;
/**
* 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.
*
* - - -
*/
topic?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a Notification resource.
*/
export interface NotificationArgs {
/**
* The name of the bucket.
*/
bucket: pulumi.Input<string>;
/**
* A set of key/value attribute pairs to attach to each Cloud PubSub message published for this notification subscription
*/
customAttributes?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* 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"`
*/
eventTypes?: pulumi.Input<pulumi.Input<string>[]>;
/**
* 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.
*/
objectNamePrefix?: pulumi.Input<string>;
/**
* The desired content of the Payload. One of `"JSON_API_V1"` or `"NONE"`.
*/
payloadFormat: pulumi.Input<string>;
/**
* 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.
*
* - - -
*/
topic: pulumi.Input<string>;
}