# HttpLambdaIntegration

The Lambda Proxy integration resource for HTTP API.

Extends: [HttpRouteIntegration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteIntegration.html) › HttpLambdaIntegration

- Source: [`aws-apigatewayv2-integrations/lib/http/lambda.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2-integrations/lib/http/lambda.ts#L59)
- Type last changed: v2.114.0 · 5 Dec 2023

## Example

TypeScript:

```ts
import { HttpUrlIntegration, HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

const getBooksIntegration = new HttpUrlIntegration('GetBooksIntegration', 'https://get-books-proxy.example.com');

declare const bookStoreDefaultFn: lambda.Function;
const bookStoreDefaultIntegration = new HttpLambdaIntegration('BooksIntegration', bookStoreDefaultFn);

const httpApi = new apigwv2.HttpApi(this, 'HttpApi');

httpApi.addRoutes({
  path: '/books',
  methods: [ apigwv2.HttpMethod.GET ],
  integration: getBooksIntegration,
});
httpApi.addRoutes({
  path: '/books',
  methods: [ apigwv2.HttpMethod.ANY ],
  integration: bookStoreDefaultIntegration,
});
```

Python:

```python
from aws_cdk.aws_apigatewayv2_integrations import HttpUrlIntegration, HttpLambdaIntegration

# book_store_default_fn: lambda.Function

get_books_integration = HttpUrlIntegration("GetBooksIntegration", "https://get-books-proxy.example.com")
book_store_default_integration = HttpLambdaIntegration("BooksIntegration", book_store_default_fn)

http_api = apigwv2.HttpApi(self, "HttpApi")

http_api.add_routes(
    path="/books",
    methods=[apigwv2.HttpMethod.GET],
    integration=get_books_integration
)
http_api.add_routes(
    path="/books",
    methods=[apigwv2.HttpMethod.ANY],
    integration=book_store_default_integration
)
```

Java:

```java
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpUrlIntegration;
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpLambdaIntegration;

Function bookStoreDefaultFn;

HttpUrlIntegration getBooksIntegration = new HttpUrlIntegration("GetBooksIntegration", "https://get-books-proxy.example.com");
HttpLambdaIntegration bookStoreDefaultIntegration = new HttpLambdaIntegration("BooksIntegration", bookStoreDefaultFn);

HttpApi httpApi = new HttpApi(this, "HttpApi");

httpApi.addRoutes(AddRoutesOptions.builder()
        .path("/books")
        .methods(List.of(HttpMethod.GET))
        .integration(getBooksIntegration)
        .build());
httpApi.addRoutes(AddRoutesOptions.builder()
        .path("/books")
        .methods(List.of(HttpMethod.ANY))
        .integration(bookStoreDefaultIntegration)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AwsApigatewayv2Integrations;

Function bookStoreDefaultFn;

var getBooksIntegration = new HttpUrlIntegration("GetBooksIntegration", "https://get-books-proxy.example.com");
var bookStoreDefaultIntegration = new HttpLambdaIntegration("BooksIntegration", bookStoreDefaultFn);

var httpApi = new HttpApi(this, "HttpApi");

httpApi.AddRoutes(new AddRoutesOptions {
    Path = "/books",
    Methods = new [] { HttpMethod.GET },
    Integration = getBooksIntegration
});
httpApi.AddRoutes(new AddRoutesOptions {
    Path = "/books",
    Methods = new [] { HttpMethod.ANY },
    Integration = bookStoreDefaultIntegration
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"

var bookStoreDefaultFn Function

getBooksIntegration := awscdk.NewHttpUrlIntegration(jsii.String("GetBooksIntegration"), jsii.String("https://get-books-proxy.example.com"))
bookStoreDefaultIntegration := awscdk.NewHttpLambdaIntegration(jsii.String("BooksIntegration"), bookStoreDefaultFn)

httpApi := apigwv2.NewHttpApi(this, jsii.String("HttpApi"))

httpApi.AddRoutes(&AddRoutesOptions{
	Path: jsii.String("/books"),
	Methods: []HttpMethod{
		apigwv2.HttpMethod_GET,
	},
	Integration: getBooksIntegration,
})
httpApi.AddRoutes(&AddRoutesOptions{
	Path: jsii.String("/books"),
	Methods: []HttpMethod{
		apigwv2.HttpMethod_ANY,
	},
	Integration: bookStoreDefaultIntegration,
})
```

## Initializer

TypeScript:

```ts
new HttpLambdaIntegration(id: string, handler: IFunction, props?: HttpLambdaIntegrationProps)
```

Python:

```python
HttpLambdaIntegration(id: str, handler: IFunction, props: typing.Optional[HttpLambdaIntegrationProps] = None)
```

Java:

```java
new HttpLambdaIntegration(String id, IFunction handler, HttpLambdaIntegrationProps props)
```

C# / .NET:

```csharp
new HttpLambdaIntegration(string id, IFunction handler, HttpLambdaIntegrationProps? props = null)
```

Golang:

```go
NewHttpLambdaIntegration(Id *string, Handler IFunction, Props HttpLambdaIntegrationProps)
```

## Methods

- `bind(_options: HttpRouteIntegrationBindOptions): HttpRouteIntegrationConfig` — Bind this integration to the route.
