# EdgeLambda

Represents a Lambda function version and event type when using Lambda@Edge.

The type of the `AddBehaviorOptions.edgeLambdas` property.

- Source: [`aws-cloudfront/lib/distribution.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts#L1109)

## Example

TypeScript:

```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 edgeLambda: cloudfront.EdgeLambda = {
  eventType: cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
  functionVersion: version,

  // the properties below are optional
  includeBody: false,
};
```

Python:

```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

edge_lambda = cloudfront.EdgeLambda(
    event_type=cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
    function_version=version,

    # the properties below are optional
    include_body=False
)
```

Java:

```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;

EdgeLambda edgeLambda = EdgeLambda.builder()
        .eventType(LambdaEdgeEventType.ORIGIN_REQUEST)
        .functionVersion(version)

        // the properties below are optional
        .includeBody(false)
        .build();
```

C# / .NET:

```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 edgeLambda = new EdgeLambda {
    EventType = LambdaEdgeEventType.ORIGIN_REQUEST,
    FunctionVersion = version,

    // the properties below are optional
    IncludeBody = false
};
```

Golang:

```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

edgeLambda := &EdgeLambda{
	EventType: awscdk.Aws_cloudfront.LambdaEdgeEventType_ORIGIN_REQUEST,
	FunctionVersion: version,

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

## Properties

- `eventType`: [LambdaEdgeEventType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.LambdaEdgeEventType.html) (required) — The type of event in response to which should the function be invoked.

- `functionVersion`: [IVersion](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IVersion.html) (required) — The version of the Lambda function that will be invoked.

  **Note**: it's not possible to use the '$LATEST' function version for Lambda@Edge!

- `includeBody`: boolean = false — Allows a Lambda function to have read access to the body content.

  Only valid for "request" event types (`ORIGIN_REQUEST` or `VIEWER_REQUEST`).
  See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-include-body-access.html
