# FunctionAssociation

Represents a CloudFront function and event type when using CF Functions.

The type of the `AddBehaviorOptions.functionAssociations` property.

- Source: [`aws-cloudfront/lib/function.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts#L275)
- Type last changed: v2.224.0 · 13 Nov 2025

## 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_cloudfront as interfaces_cloudfront } from 'aws-cdk-lib/interfaces';

declare const functionRef: interfaces_cloudfront.IFunctionRef;
const functionAssociation: cloudfront.FunctionAssociation = {
  eventType: cloudfront.FunctionEventType.VIEWER_REQUEST,
  function: functionRef,
};
```

## Properties

- `eventType`: [FunctionEventType](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.FunctionEventType.html) (required) — The type of event which should invoke the function.

- `function`: [IFunctionRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_cloudfront.IFunctionRef.html) (required) — The CloudFront function that will be invoked.
