HttpLambdaIntegrationProps Struct
Lambda Proxy integration properties.
| Source | aws-apigatewayv2-integrations/lib/http/lambda.ts |
|---|---|
| Type last changed |
Example
ts
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
declare const booksDefaultFn: lambda.Function;
const httpApi = new apigwv2.HttpApi(this, 'HttpApi');
const getBooksIntegration = new HttpLambdaIntegration('GetBooksIntegration', booksDefaultFn, {
scopePermissionToRoute: false,
});
const createBookIntegration = new HttpLambdaIntegration('CreateBookIntegration', booksDefaultFn, {
scopePermissionToRoute: false,
});
httpApi.addRoutes({
path: '/books',
methods: [ apigwv2.HttpMethod.GET ],
integration: getBooksIntegration,
});
httpApi.addRoutes({
path: '/books',
methods: [ apigwv2.HttpMethod.POST ],
integration: createBookIntegration,
});
python
from aws_cdk.aws_apigatewayv2_integrations import HttpLambdaIntegration
# books_default_fn: lambda.Function
http_api = apigwv2.HttpApi(self, "HttpApi")
get_books_integration = HttpLambdaIntegration("GetBooksIntegration", books_default_fn,
scope_permission_to_route=False
)
create_book_integration = HttpLambdaIntegration("CreateBookIntegration", books_default_fn,
scope_permission_to_route=False
)
http_api.add_routes(
path="/books",
methods=[apigwv2.HttpMethod.GET],
integration=get_books_integration
)
http_api.add_routes(
path="/books",
methods=[apigwv2.HttpMethod.POST],
integration=create_book_integration
)
java
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpLambdaIntegration;
Function booksDefaultFn;
HttpApi httpApi = new HttpApi(this, "HttpApi");
HttpLambdaIntegration getBooksIntegration = HttpLambdaIntegration.Builder.create("GetBooksIntegration", booksDefaultFn)
.scopePermissionToRoute(false)
.build();
HttpLambdaIntegration createBookIntegration = HttpLambdaIntegration.Builder.create("CreateBookIntegration", booksDefaultFn)
.scopePermissionToRoute(false)
.build();
httpApi.addRoutes(AddRoutesOptions.builder()
.path("/books")
.methods(List.of(HttpMethod.GET))
.integration(getBooksIntegration)
.build());
httpApi.addRoutes(AddRoutesOptions.builder()
.path("/books")
.methods(List.of(HttpMethod.POST))
.integration(createBookIntegration)
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AwsApigatewayv2Integrations;
Function booksDefaultFn;
var httpApi = new HttpApi(this, "HttpApi");
var getBooksIntegration = new HttpLambdaIntegration("GetBooksIntegration", booksDefaultFn, new HttpLambdaIntegrationProps {
ScopePermissionToRoute = false
});
var createBookIntegration = new HttpLambdaIntegration("CreateBookIntegration", booksDefaultFn, new HttpLambdaIntegrationProps {
ScopePermissionToRoute = false
});
httpApi.AddRoutes(new AddRoutesOptions {
Path = "/books",
Methods = new [] { HttpMethod.GET },
Integration = getBooksIntegration
});
httpApi.AddRoutes(new AddRoutesOptions {
Path = "/books",
Methods = new [] { HttpMethod.POST },
Integration = createBookIntegration
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
var booksDefaultFn Function
httpApi := apigwv2.NewHttpApi(this, jsii.String("HttpApi"))
getBooksIntegration := awscdk.NewHttpLambdaIntegration(jsii.String("GetBooksIntegration"), booksDefaultFn, &HttpLambdaIntegrationProps{
ScopePermissionToRoute: jsii.Boolean(false),
})
createBookIntegration := awscdk.NewHttpLambdaIntegration(jsii.String("CreateBookIntegration"), booksDefaultFn, &HttpLambdaIntegrationProps{
ScopePermissionToRoute: jsii.Boolean(false),
})
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_POST,
},
Integration: createBookIntegration,
})
Properties
parameterMappingoptionalParameterMappingparameter_mappingoptionalParameterMappingparameterMappingoptionalParameterMappingParameterMappingoptionalParameterMappingParameterMappingoptionalParameterMapping #Specifies how to transform HTTP requests before sending them to the backend.
Default: undefined requests are sent to the backend unmodified
payloadFormatVersionoptionalPayloadFormatVersionpayload_format_versionoptionalPayloadFormatVersionpayloadFormatVersionoptionalPayloadFormatVersionPayloadFormatVersionoptionalPayloadFormatVersionPayloadFormatVersionoptionalPayloadFormatVersion = PayloadFormatVersion.VERSION_2_0 #Version of the payload sent to the lambda handler.
scopePermissionToRouteoptionalbooleanscope_permission_to_routeoptionalboolscopePermissionToRouteoptionalBooleanScopePermissionToRouteoptionalboolScopePermissionToRouteoptional*bool = true #Scope the permission for invoking the AWS Lambda down to the specific route associated with this integration.
If this is set to false, the permission will allow invoking the AWS Lambda from any route. This is useful for reducing the AWS Lambda policy size for cases where the same AWS Lambda function is reused for many integrations.