Migrate via Terraform
Step 1: Extract your current configuration
Inside your codebase, locate the script from DataDome.
Step 2: Map the v1 configuration to your v2 configuration
- Retrieve the specific values that you may have set to configure your DataDome Worker that are not the default value to reuse them in the Worker v2 integration.
| Name in Worker v1 | Default value | Name in Worker v2 |
|---|---|---|
| DATADOME_LICENSE_KEY | 'YOUR_DATADOME_SERVER_KEY' | DATADOME_SERVER_SIDE_KEY |
| DATADOME_JS_KEY | '' | DATADOME_CLIENT_SIDE_KEY |
| DATADOME_JS_URL | 'https://js.datadome.co/tags.js' | DATADOME_JS_URL |
| DATADOME_JS_ENDPOINT | '' | DATADOME_JS_ENDPOINT |
| DATADOME_JS_TAG_OPTIONS | '{ "ajaxListenerPath": true }’ | DATADOME_JS_TAG_OPTIONS |
| DATADOME_TIMEOUT | 300 | DATADOME_TIMEOUT |
| DATADOME_LOG_VALUES | [] | DATADOME_LOGPUSH_CONFIGURATION |
| DATADOME_URI_REGEX | null | Fused with DATADOME_URL_REGEX_INCLUSION |
| DATADOME_URL_REGEX | null | DATADOME_URL_REGEX_INCLUSION |
| DATADOME_URI_REGEX_EXCLUSION | See list of static assets below. | DATADOME_URI_REGEX_EXCLUSION |
| DATADOME_HOSTNAME_REGEX_EXCLUSION | null | Is now set inside Worker's Triggers -> Custom Domains |
| DATADOME_JS_HOSTNAME_REGEX_EXCLUSION | null | Fused with DATADOME_JS_URL_REGEX_EXCLUSION |
| DATADOME_JS_URI_REGEX_EXCLUSION | null | Fused with DATADOME_JS_URL_REGEX_INCLUSION |
| DATADOME_URL_REGEX_EXCLUSION | null | DATADOME_JS_URL_REGEX_EXCLUSION |
| DATADOME_JS_URL_REGEX | null | DATADOME_JS_URL_REGEX_INCLUSION |
| DATADOME_IP_FILTERING | null | DATADOME_IP_EXCLUSION |
| DATADOME_ENABLE_DEBUGGING | false | DATADOME_ENABLE_DEBUGGING |
| DATADOME_ENABLE_GRAPHQL_SUPPORT | false | DATADOME_ENABLE_GRAPHQL_SUPPORT |
/\.(avi|flv|mka|mkv|mov|mp4|mpeg|mpg|mp3|flac|ogg|ogm|opus|wav|webm|webp|bmp|gif|ico|jpeg|jpg|png|svg|svgz|swf|eot|otf|ttf|woff|woff2|css|less|js|map)$/i
Step 3: migrate to new version
- Download the latest version of our Cloudflare Worker script.
- Copy the file
datadome.tsinto your code base. - Update the settings in the code of
datadome.tsusing the table created in step 2. - Modify your Terraform file to update the DataDome Worker's script and add the API keys as secrets
variable "datadome_server_side_key" {}
variable "datadome_client_side_key" {}
resource "cloudflare_worker_script" "datadome_worker" {
account_id = "<CLOUDFLARE_ACCOUNT_ID>" # update value
name = "datadome_worker"
content = file("<PATH_TO_THE_DATADOME.TS_FILE") # update value
secret_text_binding {
name = "DATADOME_SERVER_SIDE_KEY"
text = var.datadome_server_side_key
}
secret_text_binding {
name = "DATADOME_CLIENT_SIDE_KEY"
text = var.datadome_client_side_key
}
}
- Create the secret for
datadome_server_side_keyto hold the value of your DataDome server-side key you can find in your DataDome Dashboard with:export TF_VAR_datadome_server_side_key=<YOUR DATADOME_SERVER_SIDE_KEY> - Create the secret for
datadome_client_side_keyto hold the value of your DataDome client-side key you can find in your DataDome Dashboard with:export TF_VAR_datadome_client_side_key=<YOUR DATADOME_CLIENT_SIDE_KEY> - Run
terraform init - Run
One ressource will be updated: the Worker script.terraform plan - Run
terraform apply - Congrats! You migrated from DataDome Worker v1 to DataDome Worker v2!
Updated 4 months ago
