Skip to content
v2.278.0

LambdaFunctionAssociation Struct ​

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_cloudfront as cloudfront } from 'aws-cdk-lib';
import { aws_lambda as lambda } from 'aws-cdk-lib';

declare const version: lambda.Version;
const lambdaFunctionAssociation: cloudfront.LambdaFunctionAssociation = {
  eventType: cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
  lambdaFunction: version,

  // the properties below are optional
  includeBody: false,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_cloudfront as cloudfront
from aws_cdk import aws_lambda as lambda_

# version: lambda.Version

lambda_function_association = cloudfront.LambdaFunctionAssociation(
    event_type=cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
    lambda_function=version,

    # the properties below are optional
    include_body=False
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.cloudfront.*;
import software.amazon.awscdk.services.lambda.*;

Version version;

LambdaFunctionAssociation lambdaFunctionAssociation = LambdaFunctionAssociation.builder()
        .eventType(LambdaEdgeEventType.ORIGIN_REQUEST)
        .lambdaFunction(version)

        // the properties below are optional
        .includeBody(false)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.CloudFront;
using Amazon.CDK.AWS.Lambda;

Version version;

var lambdaFunctionAssociation = new LambdaFunctionAssociation {
    EventType = LambdaEdgeEventType.ORIGIN_REQUEST,
    LambdaFunction = version,

    // the properties below are optional
    IncludeBody = false
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var version Version

lambdaFunctionAssociation := &LambdaFunctionAssociation{
	EventType: awscdk.Aws_cloudfront.LambdaEdgeEventType_ORIGIN_REQUEST,
	LambdaFunction: version,

	// the properties below are optional
	IncludeBody: jsii.Boolean(false),
}

Properties ​

The lambda event type defines at which event the lambda is called during the request lifecycle.
includeBodyoptionalbooleaninclude_bodyoptionalboolincludeBodyoptionalBooleanIncludeBodyoptionalboolIncludeBodyoptional*bool = false #
Allows a Lambda function to have read access to the body content.

Only valid for "request" event types (ORIGIN_REQUEST or VIEWER_REQUEST).

lambdaFunctionIVersionlambda_functionIVersionlambdaFunctionIVersionLambdaFunctionIVersionLambdaFunctionIVersion required #
A version of the lambda to associate.