Rules builder
akamai_property_rules_builder
Beta
This is a beta version of the rules builder data source. Use of this version is as is and as available while still in testing and development.
Build your property rules, includes, behaviors, and criteria into a single set of rules or a rules file.
// Your default rule information
data "akamai_property_rules_builder" "my_default_rule" {
rules_v2023_01_05 {
name = "default"
is_secure = false
comments = <<-EOT
The behaviors in the default rule apply to all requests for the property hostnames unless another rule overrides these settings.
EOT
behavior {
origin {
origin_type = "CUSTOMER"
hostname = "httpbin.org"
forward_host_header = "ORIGIN_HOSTNAME"
cache_key_hostname = "REQUEST_HOST_HEADER"
compress = true
enable_true_client_ip = false
http_port = 80
}
}
behavior {
cp_code {
value {
id = 12345
name = "main site"
}
}
}
children = [
data.akamai_property_rules_builder.compress_text_content.json
]
}
}
// Your child rule information
data "akamai_property_rules_builder" "compress_text_content" {
rules_v2023_01_05 {
name = "Compress Text Content"
behavior {
gzipResponse {
behavior = "ALWAYS"
}
}
criterion {
contentType {
matchOperator = "IS_ONE_OF"
matchWildcard = true
matchCaseSensitive = false
values = ["text/html*", "text/css*", "application/x-javascript*"]
}
}
}
}
output "my_default_rule" {
value = data.akamai_property_rules_builder.my_default_rule
}
Changes to Outputs:
+ my_default_rule = jsonencode(
{
+ rules = {
+ behaviors = [
+ {
+ name = "origin"
+ options = {
+ cacheKeyHostname = "REQUEST_HOST_HEADER"
+ compress = true
+ enableTrueClientIp = false
+ forwardHostHeader = "ORIGIN_HOSTNAME"
+ hostname = "example.org"
+ httpPort = 80
+ originType = "CUSTOMER"
}
},
+ {
+ name = "cpCode"
+ options = {
+ value = {
+ id = 12345
+ name = "main site"
}
}
},
]
+ children = [
+ {
+ behaviors = [
+ {
+ name = "gzipResponse"
+ options = {
+ behavior = "ALWAYS"
}
},
]
+ criteria = [
+ {
+ name = "contentType"
+ options = {
+ matchCaseSensitive = false
+ matchOperator = "IS_ONE_OF"
+ matchWildcard = true
+ values = [
+ "text/html*",
+ "text/css*",
+ "application/x-javascript*",
]
}
},
]
+ name = "Compress Text Content"
+ options = {}
},
]
+ comments = <<-EOT
The behaviors in the default rule apply to all requests for the property hostname(s) unless another rule overrides theses settings.
EOT
+ name = "default"
+ options = {}
}
}
)
// Uses Terraform resource local_file
resource "local_file" "rules" {
content = data.akamai_property_rules_builder.my_default_rule.json
filename = "./property-snippets/main.json"
}
// local
rules = data.akamai_property_rules_builder.my_default_rule
// reference file directly
rules = file("${path.root}/property-snippets/main.json")
Arguments
Send your rule's name, rule format version, and any of the optional arguments that build out your rule's business case.
Argument | Required | Description |
---|---|---|
name | ✔️ | The name of your rule. If you're sending the entire tree, this value is default . |
rule_format | ✔️ | The versioned schema that represents a valid rule tree. |
is_secure | Whether the default rule is secure.Not applicable for child rules. | |
behavior | A behavior for a rule. | |
variable | A list of variables for a rule.
| |
criterion | A match target for a rule. Not applicable for the default rule. | |
criteria_must_satisfy | Whether all criteria need to match or any .Not applicable for the default rule. | |
advanced_override | XML metadata of the rule. Not applicable for child rules. | |
custom_override | A rule's XML metadata.
Not applicable for child rules. | |
comments | Any comments for a rule. | |
uuid | The rule's UUID. | |
template_uuid | The rule template's UUID. | |
criteria_locked | Whether changes to criterion objects are prohibited.Not applicable for the default rule. | |
template_link | The rule's template link. |
Attributes
For any output method you chose, returned to you is your full set of rules in the rule format you passed in the request.
Updated 5 months ago