# LambdaEdgeEventType

The type of events that a Lambda@Edge function can be invoked in response to.

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

## Example

```ts
// A Lambda@Edge function added to default behavior of a Distribution
// and triggered on every request
const myFunc = new cloudfront.experimental.EdgeFunction(this, 'MyFunction', {
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});

declare const myBucket: s3.Bucket;
new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: {
    origin: new origins.S3Origin(myBucket),
    edgeLambdas: [
      {
        functionVersion: myFunc.currentVersion,
        eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
      }
    ],
  },
});
```

## Members

| Member | Description |
| --- | --- |
| `ORIGIN_REQUEST` | The origin-request specifies the request to the origin location (e.g. S3). |
| `ORIGIN_RESPONSE` | The origin-response specifies the response from the origin location (e.g. S3). |
| `VIEWER_REQUEST` | The viewer-request specifies the incoming request. |
| `VIEWER_RESPONSE` | The viewer-response specifies the outgoing response. |

## Referenced by

- [`EdgeLambda`](/v2/docs/aws-cdk-lib.aws_cloudfront.EdgeLambda).eventType
- [`LambdaFunctionAssociation`](/v2/docs/aws-cdk-lib.aws_cloudfront.LambdaFunctionAssociation).eventType
