# LambdaDestination

Use a Lambda function as a Lambda destination.

Implements: [IDestination](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IDestination.html)

- Source: [`aws-lambda-destinations/lib/lambda.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-lambda-destinations/lib/lambda.ts#L33)

## Example

TypeScript:

```ts
// Auto-extract response payload with a lambda destination
declare const destinationFn: lambda.Function;

const sourceFn = new lambda.Function(this, 'Source', {
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
  // auto-extract on success
  onSuccess: new destinations.LambdaDestination(destinationFn, {
    responseOnly: true,
  }),
})
```

Python:

```python
# Auto-extract response payload with a lambda destination
# destination_fn: lambda.Function

source_fn = lambda_.Function(self, "Source",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "lambda-handler")),
    # auto-extract on success
    on_success=destinations.LambdaDestination(destination_fn,
        response_only=True
    )
)
```

Java:

```java
// Auto-extract response payload with a lambda destination
Function destinationFn;

Function sourceFn = Function.Builder.create(this, "Source")
        .runtime(Runtime.NODEJS_LATEST)
        .handler("index.handler")
        .code(Code.fromAsset(join(__dirname, "lambda-handler")))
        // auto-extract on success
        .onSuccess(LambdaDestination.Builder.create(destinationFn)
                .responseOnly(true)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Auto-extract response payload with a lambda destination
Function destinationFn;

var sourceFn = new Function(this, "Source", new FunctionProps {
    Runtime = Runtime.NODEJS_LATEST,
    Handler = "index.handler",
    Code = Code.FromAsset(Join(__dirname, "lambda-handler")),
    // auto-extract on success
    OnSuccess = new LambdaDestination(destinationFn, new LambdaDestinationOptions {
        ResponseOnly = true
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Auto-extract response payload with a lambda destination
var destinationFn Function

sourceFn := lambda.NewFunction(this, jsii.String("Source"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("lambda-handler"))),
	// auto-extract on success
	OnSuccess: destinations.NewLambdaDestination(destinationFn, &LambdaDestinationOptions{
		ResponseOnly: jsii.Boolean(true),
	}),
})
```

## Initializer

TypeScript:

```ts
new LambdaDestination(fn: IFunction, options?: LambdaDestinationOptions)
```

Python:

```python
LambdaDestination(fn: IFunction, options: typing.Optional[LambdaDestinationOptions] = None)
```

Java:

```java
new LambdaDestination(IFunction fn, LambdaDestinationOptions options)
```

C# / .NET:

```csharp
new LambdaDestination(IFunction fn, LambdaDestinationOptions? options = null)
```

Golang:

```go
NewLambdaDestination(Fn IFunction, Options LambdaDestinationOptions)
```

## Methods

- `bind(scope: Construct, fn: IFunction, options?: DestinationOptions): DestinationConfig` — Returns a destination configuration.
