connector-cloudfront
Before getting started please read the documentation to get acquainted with edge connectors.
This repository contains two AWS lambda functions you can add to your CloudFront distribution events ViewerRequest
and ViewerResponse
to integrate queue-it functionality into your backend.
Installation
-
Download the ViewerRequest.zip
and ViewerResponse.zip
files from the latest release.
-
Set your CustomerId
, SecretKey
and ApiKey
in environmentvariables.json
file in ViewerRequest
folder.
-
Create two lambda edge functions, one for ViewerRequest
and one for ViewerResponse
and put the code from this
repository there respectively.
-
Define your desired CloudFront behaviours where you want to be protected by queue and set CloudFront events
ViewerRequest
and ViewerResponse
to point to the two functions you just created.
** Please make sure the code is living in the highest level in our lambda definition as it shown here.
Using the NPM package
Install @queue-it/connector-cloudfront
and use it like this:
- In your
ViewerRequest
lambda you need to add this.
import {onClientRequest, setIntegrationDetails} from "@queue-it/connector-cloudfront";
const queueItResponse = await onClientRequest(cloudfrontEvent);
if (queueItResponse.status) {
return queueItResponse;
}
- In your
ViewerResponse
lambda you need to add this.
import {onClientResponse} from "../";
const response = await onClientResponse(cloudfrontEvent);
return response;
Request body trigger (advanced)
The connector supports triggering on request body content. An example could be a POST call with specific item ID where
you want end-users to queue up for. For this to work, you will need to contact queue-it support, so it can be enabled on
your GO Queue-it platform account.
Once enabled, you will need to check the Include body
checkbox in the ViewerRequest
function associations. This can
be done by editing your CloudFront distribution behaviors.
Queue-it variables
Variable | Required | Value |
---|
QUEUEIT_CUSTOMER_ID | Yes | Find your Customer ID in the GO Queue-it platform. |
QUEUEIT_SECRET_KEY | Yes | Your 72 char secret key as specified in Go Queue-it self-service platform. |
QUEUEIT_API_KEY | Yes | Find your API key in the GO Queue-it platform. |
QUEUEIT_ENQT_ENABLED | No | Default: true If you do not need to add the enqueue token then set the value to false. |
QUEUEIT_ENQT_VALIDITY_TIME | No | Recommandation: 240000 ms or > 30000 ms |
QUEUEIT_ENQT_KEY_ENABLED | No | Default: false If you need to include custom key in the enqueue token then set value to true. |
EnqueueToken
An enqueue token can be used for allowing access to waiting room(s). Any user without it can't join the queue. The token will be included when the user is redirected from the connector to the queue.
QueueToken package has been used to generate this token. The generated token will be valid for 4 minute.
Follow the steps below to enable use of enqueue token:
- The waiting room should be configured to require token to enter it. Use Queue-it Go platform or API to setup your waiting room.
- Add a variable with name QUEUEIT_ENQT_ENABLED in settings as mentioned in the example code and value 'true'.