import * as pulumi from "@pulumi/pulumi"; import * as outputs from "../types/output"; /** * Provides details about the notification configuration of an S3 bucket. * * Useful when `aws.s3.BucketNotification` is the right resource but the bucket already has notifications you do not manage. Read the existing notifications with this data source and re-emit them — alongside your own — in a single `aws.s3.BucketNotification` resource. See issue #501 for the longer story. For sharing a bucket across many independent consumers, enabling EventBridge on the resource is usually a better fit. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.s3.getBucketNotification({ * bucket: "example-bucket", * }); * ``` * * ### Conditionally Subscribe via EventBridge * * When the bucket forwards events to Amazon EventBridge, independent consumers can subscribe with their own `aws.cloudwatch.EventRule` resources. Use this data source to subscribe only when EventBridge is in fact enabled on the bucket. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * export = async () => { * const shared = await aws.s3.getBucketNotification({ * bucket: "shared-bucket", * }); * const s3ObjectCreated: aws.cloudwatch.EventRule[] = []; * for (let range = 0; range < (shared.eventbridge ? 1 : 0); range++) { * s3ObjectCreated.push(new aws.cloudwatch.EventRule(`s3_object_created-${range}`, { * name: "shared-bucket-object-created", * description: "S3 object-created events from the shared bucket.", * eventPattern: JSON.stringify({ * source: ["aws.s3"], * "detail-type": ["Object Created"], * detail: { * bucket: { * name: [shared.bucket], * }, * }, * }), * })); * } * } * ``` * * ### Read Existing Notifications and Re-emit Them * * The S3 [`PutBucketNotificationConfiguration`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotificationConfiguration.html) API replaces the entire notification configuration on every call, so a single `aws.s3.BucketNotification` resource owns the bucket. To preserve notifications already on the bucket — or to mirror one bucket's configuration onto another — read them with this data source and pass them through `dynamic` blocks. The data source's output shape matches the resource's input shape, so each block forwards directly. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const existing = aws.s3.getBucketNotification({ * bucket: exampleAwsS3Bucket.id, * }); * const example = new aws.s3.BucketNotification("example", { * lambdaFunctions: existing.then(existing => .map(entry => ({ * id: entry.id, * lambdaFunctionArn: entry.lambdaFunctionArn, * events: entry.events, * filterPrefix: entry.filterPrefix, * filterSuffix: entry.filterSuffix, * }))), * queues: existing.then(existing => .map(entry2 => ({ * id: entry2.id, * queueArn: entry2.queueArn, * events: entry2.events, * filterPrefix: entry2.filterPrefix, * filterSuffix: entry2.filterSuffix, * }))), * topics: existing.then(existing => .map(entry3 => ({ * id: entry3.id, * topicArn: entry3.topicArn, * events: entry3.events, * filterPrefix: entry3.filterPrefix, * filterSuffix: entry3.filterSuffix, * }))), * bucket: exampleAwsS3Bucket.id, * eventbridge: existing.then(existing => existing.eventbridge), * }); * ``` * * To add a new rule alongside existing ones, exclude IDs your resource owns from the iteration to avoid duplicates, and declare those rules separately: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketNotification("example", { * lambdaFunctions: [{ * id: "my-team-rule", * lambdaFunctionArn: mine.arn, * events: ["s3:ObjectRemoved:*"], * }], * bucket: exampleAwsS3Bucket.id, * }); * ``` * * > **Note:** The S3 API has no per-rule mutation primitive and no compare-and-swap, so two `pulumi up` runs from different state files writing to the same bucket can still race. For independent consumers of one bucket, EventBridge is generally a better fit. */ export declare function getBucketNotification(args: GetBucketNotificationArgs, opts?: pulumi.InvokeOptions): Promise; /** * A collection of arguments for invoking getBucketNotification. */ export interface GetBucketNotificationArgs { /** * Name of the bucket. */ bucket: string; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: string; } /** * A collection of values returned by getBucketNotification. */ export interface GetBucketNotificationResult { readonly bucket: string; /** * Whether Amazon EventBridge notifications are enabled on this bucket. */ readonly eventbridge: boolean; /** * List of Lambda function notification configurations. See `lambdaFunction` below. */ readonly lambdaFunctions: outputs.s3.GetBucketNotificationLambdaFunction[]; /** * List of SQS queue notification configurations. See `queue` below. */ readonly queues: outputs.s3.GetBucketNotificationQueue[]; readonly region: string; /** * List of SNS topic notification configurations. See `topic` below. */ readonly topics: outputs.s3.GetBucketNotificationTopic[]; } /** * Provides details about the notification configuration of an S3 bucket. * * Useful when `aws.s3.BucketNotification` is the right resource but the bucket already has notifications you do not manage. Read the existing notifications with this data source and re-emit them — alongside your own — in a single `aws.s3.BucketNotification` resource. See issue #501 for the longer story. For sharing a bucket across many independent consumers, enabling EventBridge on the resource is usually a better fit. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.s3.getBucketNotification({ * bucket: "example-bucket", * }); * ``` * * ### Conditionally Subscribe via EventBridge * * When the bucket forwards events to Amazon EventBridge, independent consumers can subscribe with their own `aws.cloudwatch.EventRule` resources. Use this data source to subscribe only when EventBridge is in fact enabled on the bucket. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * export = async () => { * const shared = await aws.s3.getBucketNotification({ * bucket: "shared-bucket", * }); * const s3ObjectCreated: aws.cloudwatch.EventRule[] = []; * for (let range = 0; range < (shared.eventbridge ? 1 : 0); range++) { * s3ObjectCreated.push(new aws.cloudwatch.EventRule(`s3_object_created-${range}`, { * name: "shared-bucket-object-created", * description: "S3 object-created events from the shared bucket.", * eventPattern: JSON.stringify({ * source: ["aws.s3"], * "detail-type": ["Object Created"], * detail: { * bucket: { * name: [shared.bucket], * }, * }, * }), * })); * } * } * ``` * * ### Read Existing Notifications and Re-emit Them * * The S3 [`PutBucketNotificationConfiguration`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotificationConfiguration.html) API replaces the entire notification configuration on every call, so a single `aws.s3.BucketNotification` resource owns the bucket. To preserve notifications already on the bucket — or to mirror one bucket's configuration onto another — read them with this data source and pass them through `dynamic` blocks. The data source's output shape matches the resource's input shape, so each block forwards directly. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const existing = aws.s3.getBucketNotification({ * bucket: exampleAwsS3Bucket.id, * }); * const example = new aws.s3.BucketNotification("example", { * lambdaFunctions: existing.then(existing => .map(entry => ({ * id: entry.id, * lambdaFunctionArn: entry.lambdaFunctionArn, * events: entry.events, * filterPrefix: entry.filterPrefix, * filterSuffix: entry.filterSuffix, * }))), * queues: existing.then(existing => .map(entry2 => ({ * id: entry2.id, * queueArn: entry2.queueArn, * events: entry2.events, * filterPrefix: entry2.filterPrefix, * filterSuffix: entry2.filterSuffix, * }))), * topics: existing.then(existing => .map(entry3 => ({ * id: entry3.id, * topicArn: entry3.topicArn, * events: entry3.events, * filterPrefix: entry3.filterPrefix, * filterSuffix: entry3.filterSuffix, * }))), * bucket: exampleAwsS3Bucket.id, * eventbridge: existing.then(existing => existing.eventbridge), * }); * ``` * * To add a new rule alongside existing ones, exclude IDs your resource owns from the iteration to avoid duplicates, and declare those rules separately: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketNotification("example", { * lambdaFunctions: [{ * id: "my-team-rule", * lambdaFunctionArn: mine.arn, * events: ["s3:ObjectRemoved:*"], * }], * bucket: exampleAwsS3Bucket.id, * }); * ``` * * > **Note:** The S3 API has no per-rule mutation primitive and no compare-and-swap, so two `pulumi up` runs from different state files writing to the same bucket can still race. For independent consumers of one bucket, EventBridge is generally a better fit. */ export declare function getBucketNotificationOutput(args: GetBucketNotificationOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output; /** * A collection of arguments for invoking getBucketNotification. */ export interface GetBucketNotificationOutputArgs { /** * Name of the bucket. */ bucket: pulumi.Input; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: pulumi.Input; } //# sourceMappingURL=getBucketNotification.d.ts.map