Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(terraform-validations): add terraform validations #4

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions assets/example.tf
Original file line number Diff line number Diff line change
@@ -1,44 +1,82 @@
resource "random_string" "integration_path" {
resource "random_string" "fpjs_integration_path" {
length = 8
special = false
lower = true
upper = false
}

resource "random_string" "agent_path" {
resource "random_string" "fpjs_agent_path" {
length = 8
special = false
lower = true
upper = false
}

resource "random_string" "result_path" {
resource "random_string" "fpjs_result_path" {
length = 8
special = false
lower = true
upper = false
}

variable "fpjs_integration_path" {
type = string
validation {
condition = can(regex("(^$|^[a-zA-Z0-9-]+$)", var.fpjs_integration_path))
error_message = "Variable value must be a valid URL path"
}
}

variable "fpjs_agent_path" {
type = string
validation {
condition = can(regex("(^$|^[a-zA-Z0-9-]+$)", var.fpjs_agent_path))
error_message = "Variable value must be a valid URL path"
}
}

variable "fpjs_result_path" {
type = string
validation {
condition = can(regex("(^$|^[a-zA-Z0-9-]+$)", var.fpjs_result_path))
error_message = "Variable value must be a valid URL path"
}
}

variable "fpjs_proxy_secret" {
type = string
validation {
condition = can(regex("^([a-zA-Z0-9-])+$", var.fpjs_proxy_secret))
error_message = "Variable value must follow Fingerprint Proxy Secret pattern"
}
}

locals {
fpjs_integration_path = "${var.fpjs_integration_path != "" ? var.fpjs_integration_path : random_string.fpjs_integration_path.result}"
fpjs_agent_path = "${var.fpjs_agent_path != "" ? var.fpjs_agent_path : random_string.fpjs_agent_path.result}"
fpjs_result_path = "${var.fpjs_result_path != "" ? var.fpjs_result_path : random_string.fpjs_result_path.result}"
}

data "akamai_property_rules_template" "rules" {
template_file = abspath("${path.root}/rules/main.json") # Add fingerprint.json file to your rules children
variables {
name = "fpjs_integration_path"
value = random_string.integration_path.result
value = local.fpjs_integration_path
type = "string"
}
variables {
name = "fpjs_agent_path"
value = random_string.agent_path.result
value = local.fpjs_agent_path
type = "string"
}
variables {
name = "fpjs_result_path"
value = random_string.result_path.result
value = local.fpjs_result_path
type = "string"
}
variables {
name = "fpjs_proxy_secret"
value = "" # Replace value with your own Fingerprint Proxy Secret
value = var.fpjs_proxy_secret
type = "string"
}
}
}