UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

113 lines (112 loc) 4.58 kB
import * as pulumi from "@pulumi/pulumi"; import { Bucket } from "./bucket"; import * as lambda from "../lambda"; /** * Arguments to help customize a notification subscription for a bucket. */ export interface CommonBucketSubscriptionArgs { /** * An optional prefix to filter down notifications. See * aws.s3.BucketNotification.lambdaFunctions for more details. */ filterPrefix?: string; /** * An optional suffix to filter down notifications. See * aws.s3.BucketNotification.lambdaFunctions for more details. */ filterSuffix?: string; } export interface BucketEventSubscriptionArgs extends CommonBucketSubscriptionArgs { /** * Events to subscribe to. For example: "[s3:ObjectCreated:*]". Cannot be empty. */ events: string[]; } /** * Arguments to specifically control a subscription to 'ObjectCreated' notifications on a bucket.If * more events than just 'ObjectCreated' events are desired, the 'subscribe' function should be used * instead. */ export interface ObjectCreatedSubscriptionArgs extends CommonBucketSubscriptionArgs { event?: "*" | "Put" | "Post" | "Copy" | "CompleteMultipartUpload"; } /** * Arguments to specifically control a subscription to 'ObjectRemoved' notifications on a bucket. If * more events than just 'ObjectRemoved' events are desired, the 'subscribe' function should be used * instead. */ export interface ObjectRemovedSubscriptionArgs extends CommonBucketSubscriptionArgs { event?: "*" | "Delete" | "DeleteMarkerCreated"; } export interface BucketEvent { Records?: BucketRecord[]; } export interface BucketRecord { eventVersion: string; eventSource: string; awsRegion: string; eventTime: string; eventName: string; userIdentity: { principalId: string; }; requestParameters: { sourceIPAddress: string; }; responseElements: { "x-amz-request-id": string; "x-amz-id-2": string; }; s3: { s3SchemaVersion: string; configurationId: string; bucket: { name: string; ownerIdentity: { principalId: string; }; arn: string; }; object: { key: string; size: number; eTag: string; versionId?: string; sequencer: string; }; }; } export type BucketEventHandler = lambda.EventHandler<BucketEvent, void>; /** * A component corresponding to a single underlying aws.s3.BucketNotification created for a bucket. * Note: due to the AWS requirement that all notifications for a bucket be defined at once, the * actual aws.s3.BucketNotification instances will only be created once the pulumi program runs to * completion and all subscriptions have been heard about. */ export declare class BucketEventSubscription extends lambda.EventSubscription { readonly bucket: Bucket; constructor(name: string, bucket: Bucket, handler: BucketEventHandler, args: BucketEventSubscriptionArgs, opts?: pulumi.ComponentResourceOptions); } declare module "./bucket" { interface Bucket { /** * Creates a new subscription to events fired from this Bucket to the handler provided, * along with options to control the behavior of the subscription. The handler will be * called whenever a matching [s3.Object] is created. */ onObjectCreated(name: string, handler: BucketEventHandler, args?: ObjectCreatedSubscriptionArgs, opts?: pulumi.ComponentResourceOptions): BucketEventSubscription; /** * Creates a new subscription to events fired from this Bucket to the handler provided, * along with options to control the behavior of the subscription. The handler will be * called whenever an matching [s3.Object] is removed. */ onObjectRemoved(name: string, handler: BucketEventHandler, args?: ObjectRemovedSubscriptionArgs, opts?: pulumi.ComponentResourceOptions): BucketEventSubscription; /** * Creates a new subscription to events fired from this Bucket to the handler provided, * along with options to control the behavior of the subscription. This function should be * used when full control over the subscription is wanted, and other helpers (like * onObjectCreated/onObjectRemoved) are not sufficient. */ onEvent(name: string, handler: BucketEventHandler, args: BucketEventSubscriptionArgs, opts?: pulumi.ComponentResourceOptions): BucketEventSubscription; } }