pulumi_wasm_providers_gcp_mini::storage

Module notification

source
Expand description

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 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 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

resources:
  notification:
    type: gcp:storage:Notification
    properties:
      bucket: ${bucket.name}
      payloadFormat: JSON_API_V1
      topic: ${topic.id}
      eventTypes:
        - OBJECT_FINALIZE
        - OBJECT_METADATA_UPDATE
      customAttributes:
        new-attribute: new-attribute-value
    options:
      dependsOn:
        - ${binding}
  binding:
    type: gcp:pubsub:TopicIAMBinding
    properties:
      topic: ${topic.id}
      role: roles/pubsub.publisher
      members:
        - serviceAccount:${gcsAccount.emailAddress}
  # End enabling notifications
  bucket:
    type: gcp:storage:Bucket
    properties:
      name: default_bucket
      location: US
  topic:
    type: gcp:pubsub:Topic
    properties:
      name: default_topic
variables:
  # Enable notifications by giving the correct IAM permission to the unique service account.
  gcsAccount:
    fn::invoke:
      function: gcp:storage:getProjectServiceAccount
      arguments: {}

§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:

$ pulumi import gcp:storage/notification:Notification default {{bucket_name}}/notificationConfigs/{{id}}

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments