Deploy Fastly VCL using Terraform Module

📘

Before you start: Read the general Fastly VCL guide

This document only covers deploying the Fingerprint Fastly VCL proxy integration using the official Terraform module. It assumes you have already read the general Fastly VCL guide and completed the following steps:

  • Step 1: You have issued a proxy secret in the Fingerprint Dashboard (PROXY_SECRET).
  • Step 2: You have defined the path variables for the integration (INTEGRATION_PATH, AGENT_SCRIPT_DOWNLOAD_PATH, GET_RESULT_PATH)

If you want to deploy manually using the Fastly web interface instead of the Terraform module to install the integration, see Deploy Fastly VCL manually.

🚧

Limitations

This integration is exclusively supported for customers on the Enterprise Plan. Other customers are encouraged to use Custom subdomain setup or Cloudflare Proxy Integration.

Step 3.1: Get a Fastly API token

Grab your existing Fastly API token or create a new one.

Step 3.2: Add and configure the Terraform module

Create the main.tf file in your Terraform project directory. Populate the properties with the values generated in the previous steps.

terraform {
  required_version = ">=1.5"
}

module "fingerprint_fastly_vcl_integration" {
  source                     = "fingerprintjs/vcl-fingerprint-proxy-integration/fastly"
  fastly_api_token           = "FASTLY_API_TOKEN"
  integration_domain         = "metrics.yourwebsite.com"
  integration_path           = "INTEGRATION_PATH"
  agent_script_download_path = "AGENT_SCRIPT_DOWNLOAD_PATH"
  get_result_path            = "GET_RESULT_PATH"
  main_host                  = "origin.mydomain.com" # Your website's origin server domain
  proxy_secret               = "abcdef01234"
}
  • Proxied identification requests without a valid proxy secret will result in an authentication error and not receive identification results.
  • This module configures a Fastly dictionary named fingerprint_config by default. You can change it using the dictionary_name variable, for example to avoid conflicts with your existing Fastly dictionaries. If you want to change the dictionary_name, you must also use a custom VCL asset.
    In that case, skip the download step, place your file at <project root>/assets/my_vcl_file.vcl, and set vcl_asset_name to my_vcl_file.vcl.

You can see the full list of the Terraform module's variables below:

VariableDescriptionRequiredExample
fastly_api_tokenYour Fastly API tokenRequired"ABC123...xyz"
integration_domainDomain used for the proxy integrationRequired"metrics.yourwebsite.com"
main_hostYour origin server domainRequired"yourwebsite.com"
proxy_secretYour Fingerprint proxy secretRequired"9h7jk2s1"
integration_pathPath prefix for proxy requestsRequired"kyfy7t0a"
agent_script_download_pathPath for serving the JavaScript agentRequired"cc7bu2o8"
get_result_pathPath for identification requestsRequired"sy5k3279"
dictionary_nameName of the Fastly Dictionary for config valuesOptional"fingerprint_config"
integration_nameName of the Fastly CDN serviceOptional"fingerprint-fastly-vcl-proxy-integration"
download_assetWhether to auto-download the latest VCL releaseOptionaltrue
vcl_asset_nameCustom VCL asset file if not downloading the official oneOptional"fingerprint-pro-fastly-vcl-integration.vcl"
asset_versionGitHub release version used for the VCL asset (See GitHub releases)Optional"latest"
manage_fastly_dictionary_itemsManage Fastly Dictionary items via terraform, see Fastly documentationOptionalfalse

Updating Dictionary Items

To have Terraform manage your Fastly Dictionary items, set the manage_fastly_dictionary_items variable to true. By default, these items — integration_path, get_result_path, agent_script_download_path, and proxy_secret — must be managed outside of Terraform. You can learn more about the reason behind this default behavior in the official Fastly documentation. After updating Dictionary Items, whether through Terraform or manually, it may take a few minutes for the changes to take effect.

Step 3.3: Deploy your changes

  1. Initialize Terraform:

    terraform init
  2. Import the VCL asset into the Terraform state:

    terraform apply -target=module.fingerprint_fastly_vcl_integration.module.vcl_asset

    You will get this warning: Warning: Resource targeting is in effect.... You can safely ignore it. The module is downloading the latest release artifact so that it can upload it as a VCL file in the next apply command.

  3. Deploy the integration:

    terraform apply
📘

Safari accuracy on non-Fastly websites

For maximum accuracy, both your website and your proxy integration should be served by Fastly.

You can use the Fastly VCL proxy integration even if your website is not served by Fastly, but this setup will likely limit Safari cookie lifetime to 7 days, resulting in lower accuracy. Because your website and the proxy integration 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.

Step 4: Configure your domain

In the Create a new Fastly CDN Service section, follow sub-steps 4 to 10 to complete your domain setup.

Step 5: Configure the client agent

Go back to the general Fastly VCL guide to Configure the Fingerprint client agent to use your service.

Updating the integration

The Terraform installation of the Fastly VCL proxy integration does not include any mechanism for automatic updates. To keep your integration up to date, run terraform apply regularly.

Removing the integration

To remove the integration, run:

terraform destroy