UNPKG

@pulumi/aws-serverless

Version:

Pulumi Amazon Web Services (AWS) Serverless Components.

50 lines (49 loc) 1.85 kB
import { lambda, sqs } from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; import { Handler } from "./function"; import { EventSubscription } from "./subscription"; export interface QueueEvent { Records: QueueRecord[]; } export interface QueueRecord { messageId: string; receiptHandle: string; body: string; attributes: { ApproximateReceiveCount: string; SentTimestamp: string; SenderId: string; ApproximateFirstReceiveTimestamp: string; }; messageAttributes: Record<string, any>; md5OfBody: string; eventSource: string; eventSourceARN: string; awsRegion: string; } export declare type QueueEventHandler = Handler<QueueEvent, void>; /** * Arguments to control the sqs subscription. */ export declare type QueueSubscriptionArgs = { /** * The largest number of records that AWS Lambda will retrieve. The maximum batch size supported * by Amazon Simple Queue Service is up to 10 queue messages per batch. The default setting is * 10. * * See https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html for more details. */ batchSize?: number; }; /** * Creates a new subscription to the given queue using the lambda provided, along with optional * options to control the behavior of the subscription. */ export declare function subscribe(name: string, topic: sqs.Queue, handler: QueueEventHandler, args?: QueueSubscriptionArgs, opts?: pulumi.ResourceOptions): QueueEventSubscription; export declare class QueueEventSubscription extends EventSubscription { /** * The underlying sns object created for the subscription. */ readonly eventSourceMapping: lambda.EventSourceMapping; constructor(name: string, queue: sqs.Queue, func: lambda.Function, args: QueueSubscriptionArgs, opts?: pulumi.ResourceOptions); }