Skip to content
v2.274.0

FunctionEventType Enum ​

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

Example ​

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

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 ​

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

Referenced by ​