# LambdaSubscription

Use a Lambda function as a subscription target.

Extends: LambdaSubscription
Implements: ITopicSubscription

- Source: [`aws-sns-subscriptions/lib/lambda.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-sns-subscriptions/lib/lambda.ts#L19)

## Example

```ts
import * as lambda from 'aws-cdk-lib/aws-lambda';

const myTopic = new sns.Topic(this, 'MyTopic');
declare const fn: lambda.Function;

// Lambda should receive only message matching the following conditions on message body:
// color: 'red' or 'orange'
// store: property must not be present
myTopic.addSubscription(new subscriptions.LambdaSubscription(fn, {
  filterPolicyWithMessageBody: {
    background: sns.FilterOrPolicy.policy({
      color: sns.FilterOrPolicy.filter(sns.SubscriptionFilter.stringFilter({
        allowlist: ['red', 'orange'],
      })),
    }),
    store: sns.FilterOrPolicy.filter(sns.SubscriptionFilter.notExistsFilter()),
  },
}));
```

## Initializer

```ts
new LambdaSubscription(fn: IFunction, props?: LambdaSubscriptionProps)
```

## Methods

- `bind(topic: ITopic): TopicSubscriptionConfig` — Returns a configuration for a Lambda function to subscribe to an SNS topic.
