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.
  • 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.
1

AWS IAM Setup

The AWS Lambda@Edge installation consists of three parts. Be sure to complete each part in order.

  1. Create an IAM Policy to use with an AWS IAM account
  2. Assign an AWS IAM account with required permissions
  3. 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.

  1. Navigate to the AWS Console > IAM Dashboard > Policies and click Create Policy.
  2. In Step 1, Specify permissions > Policy editor, click JSON.
  3. Replace the JSON that appears with the JSON below.
1{
2 "Version": "2012-10-17",
3 "Statement": [
4 {
5 "Effect": "Allow",
6 "Action": [
7 "lambda:CreateFunction",
8 "lambda:UpdateFunctionCode",
9 "lambda:UpdateFunctionConfiguration",
10 "lambda:PublishVersion",
11 "lambda:GetFunction",
12 "lambda:ListFunctions",
13 "lambda:InvokeFunction",
14 "lambda:EnableReplication",
15 "cloudfront:CreateDistribution",
16 "cloudfront:UpdateDistribution",
17 "cloudfront:GetDistribution",
18 "cloudfront:ListDistributions",
19 "cloudfront:ListCachePolicies",
20 "cloudfront:CreateCachePolicy",
21 "cloudfront:GetDistributionConfig",
22 "iam:CreateRole",
23 "iam:AttachRolePolicy",
24 "iam:PutRolePolicy",
25 "iam:PassRole",
26 "iam:GetRole",
27 "iam:ListRoles",
28 "iam:GetUser"
29 ],
30 "Resource": "*"
31 }
32 ]
33}
  1. Click Next and provide a Policy name.
  2. 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

  1. Navigate to the AWS Console > IAM Dashboard > Users and click Create user.
  2. In Step 1, Specify User Details, provide a user name and click Next.
  3. In Step 2, Set permissions:
    1. In the Permissions options, choose Attach policies directly.
    2. In the Permissions policies area that appears, click the checkbox next to the Policy you created in Create an AWS IAM Policy.
  4. 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

  1. Navigate to the AWS Console > IAM Dashboard > Users.
  2. Click the user you want to add permissions to.
  3. Under Permissions > Permissions policies, click Add permissions > Add permissions.
  4. From Step 1, Add permissions:
    1. In Permissions options, choose Attack policies directly.
    2. In the Permissions policies area that appears, click the checkbox next to the Policy you created in Create an AWS IAM Policy.
  5. Click Next. Then, in Step 2, Review, click Add permissions.

Next, move on to Create an AWS Access Key.

Create an AWS Access key

  1. Navigate to the AWS Console > IAM Dashboard > Users and select the user you just created or edited from Assign AWS IAM account permissions.
  2. Click the Security credentials tab.
  3. Navigate to the Access keys area and click Create access key.
  4. In Step 1, Access key best practices & alternatives, select Other as the Use case. Then, click Next.
  5. If you’d like, add a description. Otherwise, click Create access key.
  6. 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!

2

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.

Additional setup for Windows users

If you’re using Windows, you also need to complete additional steps to set up Docker:

  1. In your Windows search bar, search for and open Turn Windows features on or off.
  2. Find the Windows Hypervisor Platform feature and click its checkbox to enable it.
  3. Click OK to save your changes.
  4. Open Windows PowerShell as an Administrator.
  5. Copy and paste in C:\Windows\System32\wsl.exe --update --web-download, then hit Enter.
  1. Pull the Docker image by running:
$docker pull us-docker.pkg.dev/hmn-registry/docker-public/cdn-enforcer-deploy-tool
  1. Navigate to the directory where you saved enforcerConfig.json.
  2. Run the Deploy Tool with the following:
$docker run --rm -v $PWD:/app/local -it us-docker.pkg.dev/hmn-registry/docker-public/cdn-enforcer-deploy-tool
3

Deploy the Enforcer

After you run the Deploy Tool, you’ll be prompted with steps to deploy the Enforcer.

  1. When prompted, select AWS Lambda@Edge and hit Enter.
$🚀 HUMAN CDN Enforcer Deploy Tool 🚀
$? Which platform do you want to deploy to? (Use arrow keys)
$ ...
$ AWS Lambda@Edge
$ ...
  1. Follow the prompts that appear to complete the setup process.
  2. After you complete the setup, confirm that the displayed details are correct, then enter y to deploy the Enforcer.