Skip to main content
Version: 4.6.1-saas

Installation and Initialization

This guide explains the installation and initialization process for NetFUNNEL CloudFront agent.


Step 1: Get Client ID

  1. Go to NetFUNNEL console
  2. Click the profile icon in the top right
  3. Select Integration Credentials menu
  4. Copy Client ID
Client ID Location

You can find it in the Integration Credentials menu after clicking the profile icon in the top right of the console screen.


Step 2: IAM Setup

Create IAM Role

  1. AWS IAM console → Click [Roles]
  2. Click [Create role]
  3. Trusted entity: Select AWS service
  4. Use case: Select Lambda
  5. Click [Next: Permissions]

Configure Trust Entity

  1. After creating the role, click [Trust Entity] tab
  2. Edit Trust Entity and paste the following JSON:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"edgelambda.amazonaws.com",
"lambda.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}

Attach Policy

  1. Click [Permissions] tab
  2. [Add permissions] → Click [Create inline policy]
  3. Paste the following policy in the JSON tab (allows Lambda function to create and write CloudWatch logs):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}

Step 3: Create Lambda Function

Region Selection

Lambda function must be created in the us-east-1 (N. Virginia) region. This is an AWS requirement, as this region serves as the central location for replicating functions globally.

Create Lambda Function

  1. Go to Lambda console in us-east-1 region
  2. Click [Create function]
  3. Select [Author from scratch]
  4. Enter function name (e.g., "netfunnel-agent")
  5. Runtime: Select Node.js
  6. Select the IAM role created above
  7. Click [Create function]

Configure Lambda Function

  1. Download netfunnel-cloudfront-agent.js file from https://agent-lib.stclab.com/agents/cdn/cloudfront/netfunnel-cloudfront-agent-latest.js
  2. Upload netfunnel-cloudfront-agent.js file to code source in [Code] tab
  3. Open index.mjs file and write the following code:
import handleEvent from './netfunnel-cloudfront-agent.js';
const config = {
clientID: "{{CLIENT_ID}}",
}
export const handler = async (event) => {
return await handleEvent(event, config)
};

Check CLIENT_ID in the NetFUNNEL console.

  1. Create package.json file and paste the following code:
{
"name": "cloudfront-agent",
"type": "module",
"dependencies": {}
}
  1. Click [Deploy] button
  2. [Versions] tab → Click [Publish new version]

Step 4: CloudFront Configuration

Connect Lambda@Edge

  1. Select CloudFront Distribution to apply Lambda@Edge
  2. Select an item in [Behaviors] tab and click [Edit]
  3. In Function associations at the bottom:
    • Viewer request: Enter the created Lambda function ARN (including version, e.g., :1)
    • Viewer response: Enter the created Lambda function ARN (including version, e.g., :1)
  4. Click [Save changes]

CloudFront Invalidation

  1. Click [Invalidations] tab
  2. Click [Create invalidation]
  3. Object paths: Enter /*
  4. Click [Create invalidation]
  5. After invalidation is complete, Lambda@Edge connection will be applied to CloudFront

Next Steps