@pulumi/aws-serverless
Version:
Pulumi Amazon Web Services (AWS) Serverless Components.
91 lines (90 loc) • 3.74 kB
TypeScript
import { lambda, s3 } from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";
import { Handler } from "./function";
import { EventSubscription } from "./subscription";
/**
* Arguments to help customize a notification subscription for a bucket.
*/
export interface SimpleBucketSubscriptionArgs {
/**
* An optional prefix or suffix to filter down notifications. See
* aws.s3.BucketNotification.lambdaFunctions for more details.
*/
filterPrefix?: string;
filterSuffix?: string;
}
export interface BucketSubscriptionArgs extends SimpleBucketSubscriptionArgs {
/**
* Events to subscribe to. For example: "s3:ObjectCreated:*". Cannot be empty.
*/
events: string[];
}
/**
* Arguments to specifically control a subscription to 'put' notifications on a bucket.
* Specifically, 'events' should not be provided as they will be assumed to be "s3:ObjectCreated:*".
* If different events are desired, the 'subscribe' function should be used instead.
*/
export declare type BucketPutArgs = SimpleBucketSubscriptionArgs;
/**
* Arguments to specifically control a subscription to 'delete' notifications on a bucket.
* Specifically, 'events' should not be provided as they will be assumed to be "s3:ObjectRemoved:*".
* If different events are desired, the 'subscribe' function should be used instead.
*/
export declare type BucketDeleteArgs = SimpleBucketSubscriptionArgs;
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 declare type BucketEventHandler = Handler<BucketEvent, void>;
export declare function onPut(name: string, bucket: s3.Bucket, handler: BucketEventHandler, args?: BucketPutArgs, opts?: pulumi.ResourceOptions): BucketEventSubscription;
export declare function onDelete(name: string, bucket: s3.Bucket, handler: BucketEventHandler, args?: BucketDeleteArgs, opts?: pulumi.ResourceOptions): BucketEventSubscription;
/**
* Creates a new subscription to the given bucket using the lambda provided, along with optional
* 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 onPut/onDelete) are not
* sufficient.
*/
export declare function onEvent(name: string, bucket: s3.Bucket, handler: BucketEventHandler, args: BucketSubscriptionArgs, opts?: pulumi.ResourceOptions): BucketEventSubscription;
/**
* 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 EventSubscription {
constructor(name: string, bucket: s3.Bucket, func: lambda.Function, args: BucketSubscriptionArgs, opts?: pulumi.ResourceOptions);
}