aws-cdk-lib.aws_cloudfront.FunctionEventType

enum FunctionEventType

LanguageType name
.NETAmazon.CDK.AWS.CloudFront.FunctionEventType
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#FunctionEventType
Javasoftware.amazon.awscdk.services.cloudfront.FunctionEventType
Pythonaws_cdk.aws_cloudfront.FunctionEventType
TypeScript (source)aws-cdk-lib » aws_cloudfront » FunctionEventType

The type of events that a CloudFront function can be invoked in response to.

Example

// Add a cloudfront Function to a Distribution
const cfFunction = new cloudfront.Function(this, 'Function', {
  code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'),
});

declare const s3Bucket: s3.Bucket;
new cloudfront.Distribution(this, 'distro', {
  defaultBehavior: {
    origin: new origins.S3Origin(s3Bucket),
    functionAssociations: [{
      function: cfFunction,
      eventType: cloudfront.FunctionEventType.VIEWER_REQUEST,
    }],
  },
});

Members

NameDescription
VIEWER_REQUESTThe viewer-request specifies the incoming request.
VIEWER_RESPONSEThe viewer-response specifies the outgoing response.

VIEWER_REQUEST

The viewer-request specifies the incoming request.


VIEWER_RESPONSE

The viewer-response specifies the outgoing response.