Your functions will automatically trigger in response to the following Amazon CloudFront events:
Viewer Request - This event occurs when an end-user or a device on the Internet makes an HTTP(S) request to CloudFront, and the request arrives at the edge location closest to that user.
Viewer Response - This event occurs when the CloudFront server at the edge is ready to respond to the end user or the device that made the request.
Origin Request - This event occurs when the CloudFront edge server does not already have the requested object in its cache, and the viewer request is ready to be sent to your backend origin web server (e.g. Amazon EC2, or Application Load Balancer, or Amazon S3).
Origin Response - This event occurs when the CloudFront server at the edge receives a response from your backend origin web server.