Before you start: Read the general CloudFront guideThis document only covers deploying the Fingerprint CloudFront proxy integration to your AWS account using Terraform. It assumes you use you have already read the general AWS CloudFront Proxy Integration v2 guide and completed the following steps:
- Step 1: You have issued a proxy secret in the Fingerprint Dashboard (
FPJS_PRE_SHARED_SECRET). - Step 2: You have defined the path variables for the integration (
FPJS_BEHAVIOR_PATH,FPJS_AGENT_DOWNLOAD_PATH,FPJS_GET_RESULT_PATH)
Prerequisites
- AWS Account.
- Access to an IAM role in AWS with privileges to manage IAM roles, CloudFront distributions, Secrets Manager, Lambda Functions, and S3 Read Only access.
- Terraform project using the AWS provider with the IAM role described above.
- Terraform CLI.
Step 3: Add the Fingerprint Terraform module
Add the Fingerprint CloudFront integration Terraform module into your Terraform project.- Use the proxy secret created in Step 1 as
fpjs_shared_secret. - Use the path variables defined in Step 2 as
fpjs_get_result_pathandfpjs_agent_download_path. - Make sure to deploy your integration in the
us-east-1AWS region.- Due to AWS limitations, Lambda functions must be deployed in the
us-east-1region. - The Terraform module pulls the Lambda function source code from an S3 bucket in the
us-east-1region.
- Due to AWS limitations, Lambda functions must be deployed in the
- Make sure your AWS CLI has a policy allowing it to read from S3 buckets, for example
AmazonS3ReadOnlyAccess.
fingerprint.tf
terraform init to install the module. The Terraform module source code is available on GitHub.
You can update the module by running terraform init -upgrade. Specify the version constraint according to your needs.
Note: Proxy secret requiredProxied identification requests without a valid proxy secret will result in an authentication error and not receive identification results.
Step 4: Use Terraform module outputs in your CloudFront distribution
In this step, choose between using an existing CloudFront distribution or creating a new one. The module’s GitHub repository contains example projects for both approaches.A) Use an existing CloudFront distribution (recommended)
If your website is already running on CloudFront, you can use the same distribution and domain for the proxy integration. The proxy endpoints will be available on your chosen path such asyourwebsite.com/random-path/...
This is the recommended setup. Your website and the proxy function will be same-site, served from the same IP address or IP address range. Having the same or similar IP improves cookie lifetimes in Safari — they will be stored in the browser for up to one year instead of 7 days.
- Add the following code to the definition of your CloudFront distribution.
- Replace
FPJS_BEHAVIOR_PATHwith the value you defined in Step 2.
main.tf
B) Create a new CloudFront distribution
If your website is not running on CloudFront, you can create a new CloudFront distribution just for the proxy integration and serve it from a subdomain of your website likemetrics.yourwebsite.com.
This setup limits Safari cookie lifetime to 7 days. Because your website and the Lambda proxy function will likely have different IP ranges, Safari will apply the same cookie lifetime cap as for third-party CNAME cloaking. This is still an improvement over third-party cookies getting blocked entirely by Safari. But we recommend serving your website and the proxy integration using the same CloudFront distribution if possible (option A above).
- Add the following code to create a CloudFront distribution with the Fingerprint Terraform module as the default cache behavior.
- Configure the CloudFront distribution (for example
price_class,viewer_certificate,restrictions, etc.) according to your needs.
main.tf
Creating a subdomain for the new CloudFront distribution
If you use Terraform to manage your DNS records, you can also configure a subdomain for your proxy CloudFront distribution.Step 5: Apply the the Terraform changes
- Run
terraform planto verify the planned configuration changes. - Run
terraform applyto apply the changes.
Step 6: Configure the client agent
Please see the main CloudFront proxy integration guide to Configure the client agent on your website or mobile application.Updating the integration
Unlike the CloudFormation installation method, the Terraform installation of the CloudFront proxy integration does not include any mechanism for automatic updates.- The module does not include a Management lambda function or any related resources.
- No need to configure automatic updates in the Fingerprint Dashboard.
terraform apply regularly.
Defining a permission boundary for the proxy function
If you need to, you can define the proxy function’s permission boundary as an input of the Terraform module.- Access the Secret manager secret created for the integration (
secretsmanager:GetSecretValue) - Create logs (
logs:CreateLogStream,logs:CreateLogGroup,logs:PutLogEvents).
JSON