Install the AWS Lambda@Edge Enforcer
Install the AWS Lambda@Edge Enforcer
If your organization uses AWS CloudFront services, you can use HUMAN’s CloudFront Lambda@Edge Enforcer to protect against malicious behavior. This Enforcer uses AWS Lambda functions to deploy the Enforcer on your content delivery network (CDN) and determine how traffic to your organization’s server should be handled.
You can learn how to install the Enforcer with this article.
This process uses the Deploy Tool, HUMAN’s recommended method for installing and updating the Enforcer. If you prefer a manual method, see our manual installation article.
Prerequisites
- An AWS CloudFront account with the following permissions:
- Create AWS IAM policies
- Create or edit AWS IAM user permissions
- Create AWS Access Keys
- Docker or Script, depending on your preferred method to run the deploy tool.
- For Docker, see how to install Docker Desktop with their documentation.
- For Script, install the following:
- An Enforcer configuration file,
enforcerConfig.json, which you can download from the Platform Settings > Enforcers, clicking on the appropriate Enforcer, and clicking Download configuration file . This file has the basic information for Enforcer functionality, such as your Application ID and remote authorization token, already filled in. Be sure to save it in a directory you’ll remember, like/deploy.
AWS IAM Setup
The AWS Lambda@Edge installation consists of three parts. Be sure to complete each part in order.
- Create an IAM Policy to use with an AWS IAM account
- Assign an AWS IAM account with required permissions
- Create an AWS Access Key
Create an AWS IAM Policy
You need to create a new IAM Policy with the necessary permissions to deploy the AWS Lambda@Edge Enforcer.
- Navigate to the AWS Console > IAM Dashboard > Policies and click Create Policy.
- In Step 1, Specify permissions > Policy editor, click JSON.
- Replace the JSON that appears with the JSON below.
- Click Next and provide a Policy name.
- Click Create Policy.
Next, move on to Assign AWS IAM account permissions.
Assign AWS IAM account permissions
Your goal is to have at least one AWS IAM user with permission to send request to different AWS APIs. You can do this by either creating a new AWS IAM account or editing permissions for an existing account.
Unless specified, you can leave fields as their defaults or skip them.
Option 1: Create a new AWS IAM account
- Navigate to the AWS Console > IAM Dashboard > Users and click Create user.
- In Step 1, Specify User Details, provide a user name and click Next.
- In Step 2, Set permissions:
- In the Permissions options, choose Attach policies directly.
- In the Permissions policies area that appears, click the checkbox next to the Policy you created in Create an AWS IAM Policy.
- Click Next. Then, in Step 3, Review and create, click Create user.
Next, move on to Create an AWS Access Key.
Option 2: Edit an existing AWS IAM account
- Navigate to the AWS Console > IAM Dashboard > Users.
- Click the user you want to add permissions to.
- Under Permissions > Permissions policies, click Add permissions > Add permissions.
- From Step 1, Add permissions:
- In Permissions options, choose Attack policies directly.
- In the Permissions policies area that appears, click the checkbox next to the Policy you created in Create an AWS IAM Policy.
- Click Next. Then, in Step 2, Review, click Add permissions.
Next, move on to Create an AWS Access Key.
Create an AWS Access key
- Navigate to the AWS Console > IAM Dashboard > Users and select the user you just created or edited from Assign AWS IAM account permissions.
- Click the Security credentials tab.
- Navigate to the Access keys area and click Create access key.
- In Step 1, Access key best practices & alternatives, select Other as the Use case. Then, click Next.
- If you’d like, add a description. Otherwise, click Create access key.
- Copy the Access key and Secret access key that appear.
This will be the only time you’ll see the access key and secret access key, so be sure to save it before closing the page!
Run the Deploy Tool
First, download and run the Deploy Tool. You can do this by either pulling a Docker image or running a script.
Docker method
Script method
Additional setup for Windows users
If you’re using Windows, you also need to complete additional steps to set up Docker:
- In your Windows search bar, search for and open Turn Windows features on or off.
- Find the Windows Hypervisor Platform feature and click its checkbox to enable it.
- Click OK to save your changes.
- Open Windows PowerShell as an Administrator.
- Copy and paste in
C:\Windows\System32\wsl.exe --update --web-download, then hit Enter.
- Pull the Docker image by running:
- Navigate to the directory where you saved
enforcerConfig.json. - Run the Deploy Tool with the following:
Deploy the Enforcer
After you run the Deploy Tool, you’ll be prompted with steps to deploy the Enforcer.
- When prompted, select AWS Lambda@Edge and hit Enter.
- Follow the prompts that appear to complete the setup process.
- After you complete the setup, confirm that the displayed details are correct, then enter
yto deploy the Enforcer.
Enable CloudWatch logs (recommended)
We recommend creating an IAM role for each Lambda you upload. This lets the function create log groups and log streams in CloudWatch. When you deploy a Lambda@Edge function, it distributes across all edge cache locations, and all logs from the Lambda related to those regions will appear in the CloudWatch logs of their respective edge cache areas. For example, if a user accesses the us-east-1 region, the corresponding logs will be found in us-east-1.