Skip to content

Commit f8e55e5

Browse files
feat: add nested integration path support
1 parent dc9560c commit f8e55e5

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

assets/example.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ resource "random_string" "fpjs_result_path" {
2525
variable "fpjs_integration_path" {
2626
type = string
2727
validation {
28-
condition = can(regex("(^$|^[a-zA-Z0-9-]+$)", var.fpjs_integration_path))
28+
condition = can(regex("(^$|^[a-zA-Z0-9/-]+$)", var.fpjs_integration_path))
2929
error_message = "Variable value must be a valid URL path"
3030
}
3131
}
@@ -58,6 +58,7 @@ locals {
5858
fpjs_integration_path = var.fpjs_integration_path != "" ? var.fpjs_integration_path : random_string.fpjs_integration_path.result
5959
fpjs_agent_path = var.fpjs_agent_path != "" ? var.fpjs_agent_path : random_string.fpjs_agent_path.result
6060
fpjs_result_path = var.fpjs_result_path != "" ? var.fpjs_result_path : random_string.fpjs_result_path.result
61+
fpjs_integration_path_escaped = replace(var.fpjs_integration_path, "/", "\\\\/")
6162
}
6263

6364
data "akamai_property_rules_template" "rules" {
@@ -67,6 +68,11 @@ data "akamai_property_rules_template" "rules" {
6768
value = local.fpjs_integration_path
6869
type = "string"
6970
}
71+
variables {
72+
name = "fpjs_integration_path_escaped"
73+
value = local.fpjs_integration_path_escaped
74+
type = "string"
75+
}
7076
variables {
7177
name = "fpjs_agent_path"
7278
value = local.fpjs_agent_path

assets/rulesTemplate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"behavior": "REGEX_REPLACE",
9595
"matchMultiple": false,
9696
"keepQueryString": true,
97-
"matchRegex": "\\/__integration_path__[\\/]?(.*)",
97+
"matchRegex": "\\/__integration_path_escaped__[\\/]?(.*)",
9898
"targetRegex": "/$1"
9999
}
100100
}
@@ -525,7 +525,7 @@
525525
"behavior": "REGEX_REPLACE",
526526
"matchMultiple": false,
527527
"keepQueryString": true,
528-
"matchRegex": "\\/__integration_path__\\/__result_path__(.*)",
528+
"matchRegex": "\\/__integration_path_escaped__\\/__result_path__(.*)",
529529
"targetRegex": "$1"
530530
}
531531
}

generators/generatePatchBody.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default function generatePatchBody({
2828

2929
let bodyString = JSON.stringify(body, null, 2)
3030
bodyString = bodyString.replace(/__integration_path__/g, integrationPath)
31+
bodyString = bodyString.replace(/__integration_path_escaped__/g, integrationPath?.replace('/', '\\\\/'))
3132
bodyString = bodyString.replace(/__agent_path__/g, agentPath)
3233
bodyString = bodyString.replace(/__result_path__/g, resultPath)
3334
bodyString = bodyString.replace(/__proxy_secret__/g, proxySecret)

generators/generateTerraformPropertyRules.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default function generateTerraformPropertyRules(options: TerraformOptions
1010
const [rulesBody, variablesBody] = [rulesTemplate, variablesTemplate].map((file) => {
1111
let bodyString = JSON.stringify(file, null, 2)
1212
bodyString = bodyString.replace(/__integration_path__/g, '${env.fpjs_integration_path}')
13+
bodyString = bodyString.replace(/__integration_path_escaped__/g, '${env.fpjs_integration_path_escaped}')
1314
bodyString = bodyString.replace(/__agent_path__/g, '${env.fpjs_agent_path}')
1415
bodyString = bodyString.replace(/__result_path__/g, '${env.fpjs_result_path}')
1516
bodyString = bodyString.replace(/__proxy_secret__/g, '${env.fpjs_proxy_secret}')

0 commit comments

Comments
 (0)