---
updatedAt: 2026-03-01T18:36:10.000Z
agentTools:
  siteIndex: https://techdocs.akamai.com/llms.txt
  projectIndex: https://techdocs.akamai.com/terraform/v9.3/llms.txt
---

# Rules template

akamai_property_rules_template

Define which JSON template files to use for your property's rule tree based on the rule template format from the [Property Manager CLI](https://github.com/akamai/cli-property-manager#set-up-property-snippets). You can also set values for variables.

> 📘
>
> For details on how to work with rule templates and define variables, see the [Rules](https://techdocs.akamai.com/terraform/v9.3/docs/rules#use-rule-templates) guide.

```json Query: Call a single template
data "akamai_property_rules_template" "my_rules" {
  template_file = abspath("${path.root}/main.json")
  variables {
    name  = "is_encrypted"
    value = true
    type  = "bool"
  }
  variables {
    name  = "ip_version"
    value = "IPV4"
    type  = "string"
  }
}

output "my_rules" {
  value = data.akamai_property_rules_template.my_rules.json
}

resource "akamai_property" "my-property" {
  name        = "MyProperty"
  product_id  = "prd_Object_Delivery"
  contract_id = "C-0N7RAC7"
  group_id    = "12345"
  rule_format = "v2023-05-30"
  rules       = data.akamai_property_rules_template.my_rules.json
}
```
```json Query: Call template files individually
data "akamai_property_rules_template" "my_rules" {
  template {
    template_data = jsonencode({
      "rules" : {
        "name" : "default",
        "children" : [
          "#include:children/compress-text.json"
        ],
        "behaviors" : [
          "#include:behaviors/origin-hostname.json",
          "#include:behaviors/origin-characteristics.json",
          "#include:behaviors/content-characteristics.json",
          "#include:behaviors/cp-code.json"
        ]
        "options" : true,
        "criteria" : [
          "#include:criteria/content-type.json"
        ],
      }
    })
    template_dir = "./rules"
  }
  variables {
    name  = "is_encrypted"
    value = true
    type  = "bool"
  }
  variables {
    name  = "ip_version"
    value = "IPV4"
    type  = "string"
  }
}

output "my_rules" {
  value = data.akamai_property_rules_template.my_rules.json
}

resource "akamai_property" "my-property" {
  name        = "MyProperty"
  product_id  = "prd_Object_Delivery"
  contract_id = "C-0N7RAC7"
  group_id    = "12345"
  rule_format = "v2023-05-30"
  rules       = data.akamai_property_rules_template.my_rules.json
}
```
```json Query: Call variable definition files
data "akamai_property_rules_template" "my_rules" {
  template_file       = abspath("${path.root}/main.json")
  var_definition_file = abspath("${path.root}/environments/variableDefinitions.json")
  var_values_file     = abspath("${path.root}/environments/dev.example.com/variables.json")
}

output "my_rules" {
  value = data.akamai_property_rules_template.my_rules.json
}

resource "akamai_property" "my-property" {
  name        = "MyProperty"
  product_id  = "prd_Object_Delivery"
  contract_id = "C-0N7RAC7"
  group_id    = "12345"
  rule_format = "v2023-05-30"
  rules       = data.akamai_property_rules_template.my_rules.json
}
```
```json Standard output
my_rules = jsonencode(
        {
          accountId       = "act_A-CCT1234"
          contractId      = "ctr_C-0N7RAC7"
          etag            = "12a3b4567cd8e9012f34567g89hi01j23kl4567"
          groupId         = "grp_12345"
          propertyId      = "prp_12345"
          propertyVersion = 2
          ruleFormat      = "v2023-05-30"
          rules           = {
              behaviors = [
                  {
                      name    = "origin"
                      options = {
                          cacheKeyHostname          = "ORIGIN_HOSTNAME"
                          compress                  = true
                          enableTrueClientIp        = true
                          forwardHostHeader         = "REQUEST_HOST_HEADER"
                          hostname                  = "example.com"
                          httpPort                  = 80
                          httpsPort                 = 443
                          ipVersion                 = "IPV4"
                          minTlsVersion             = "DYNAMIC"
                          originCertificate         = ""
                          originSni                 = true
                          originType                = "CUSTOMER"
                          ports                     = ""
                          tlsVersionTitle           = ""
                          trueClientIpClientSetting = false
                          trueClientIpHeader        = "True-Client-IP"
                          verificationMode          = "PLATFORM_SETTINGS"
                        }
                    },
                  {
                      name    = "originCharacteristics"
                      options = {
                          accessKeyEncryptedStorage = true
                          authenticationMethod      = "GCS_HMAC_AUTHENTICATION"
                          authenticationMethodTitle = ""
                          country                   = "NORTH_AMERICA"
                          gcsAccessKeyVersionGuid   = "12abcd3ef-45gh-678i-j9k12345l6m7"
                          originLocationTitle       = ""
                        }
                    },
                  {
                      name    = "contentCharacteristics"
                      options = {
                          catalogSize            = "MEDIUM"
                          contentType            = "USER_GENERATED"
                          objectSize             = "LESS_THAN_1MB"
                          popularityDistribution = "LONG_TAIL"
                        }
                    },
                  {
                      name    = "cpCode"
                      options = {
                          value = {
                              createdDate = 1708523914000
                              description = "My CP code"
                              id          = 123456
                              name        = "My CP code"
                              products    = [
                                  "Obj_Delivery",
                                ]
                            }
                        }
                    },
                ]
              children  = [
                  {
                      behaviors = [
                          {
                              name    = "gzipResponse"
                              options = {
                                  behavior = "ALWAYS"
                                }
                            },
                        ]
                      name      = "Compress Text Content"
                    },
                ]
              criteria  = [
                  {
                      name    = "contentType"
                      options = {
                          matchCaseSensitive = false
                          matchOperator      = "IS_ONE_OF"
                          matchWildcard      = true
                          values             = [
                              "text/html*",
                              "text/css*",
                              "application/x-javascript*",
                            ]
                        }
                    },
                ]
              name      = "default"
              options   = {}
            }
        }
    )
```

## Arguments

Depending on how you work with templates, pass a path to your single JSON template file or point to individual templates in the body of the declaration to get the full rule tree.

<table>
    <thead>
        <tr>
            <th>Attribute</th>
            <th>Required</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>template_file</code></td>
            <td></td>
            <td>An absolute path to your top-level JSON template file. The top-level template combines smaller, nested JSON templates to form your property rule tree.<br /><br /> <blockquote><strong>Note:</strong> This argument conflicts with the <code>template</code> argument.</blockquote></td>
        </tr>
        <tr>
            <td><code>template</code></td>
            <td></td>
            <td>
                The template you use in your configuration. Contains:
                <ul>
                    <li><code>template_data</code>. Required. The content of your JSON template as a string.</li>
                    <li><code>template_dir</code>. Required. An absolute or relative path to a directory containing your template files.</li>
                </ul>
                <br /> <blockquote><strong>Note:</strong> This argument conflicts with the <code>template_file</code> argument.</blockquote>
            </td>
        </tr>
        <tr>
            <td><code>variables</code></td>
            <td></td>
            <td>
                The definition of one or more variables. Contains:
                <ul>
                    <li><code>name</code>. Required. The name of a variable used in the template.</li>
                    <li><code>type</code>. Required. The type of a variable: <code>string</code>, <code>number</code>, <code>bool</code>, or <code>jsonBlock</code>.</li>
                    <li><code>value</code>. Required. The value of a variable passed as a string.</li>
                </ul>
                <br /> <blockquote><strong>Note:</strong> This argument conflicts with the <code>var_definition_file</code> and <code>var_values_file</code> arguments.</blockquote>
            </td>
        </tr>
        <tr>
            <td><code>var_definition_file</code></td>
            <td></td>
            <td>Required only when using <code>var_values_file</code>. An absolute path to your file containing variable definitions and defaults. <br /><br /> <blockquote><strong>Note:</strong> This argument conflicts with the <code>variables</code> argument.</blockquote></td>
        </tr>
         <tr>
            <td><code>var_values_file</code></td>
            <td></td>
            <td>Required only when using <code>var_definition_file</code>. An absolute path to your file containing variable values. <br /><br /> <blockquote><strong>Note:</strong> This argument conflicts with the <code>variables</code> argument.</blockquote></td>
        </tr>
        <tr>
            <td><code>follow_links</code></td>
            <td></td>
            <td>When set to <code>true</code>, this enables a directory with rule snippets or any of its subdirectories, defined in the <code>template_file</code> or <code>template_dir</code> argument, to be symlinks. Defaults to <code>false</code> if not set.<br /><br /> <blockquote><strong>Note:</strong> Symlinks are processed recursively. Ensure that a link doesn't point to its parent directory to avoid creating infinite recursion.</blockquote></td>
        </tr>
    </tbody>
</table>

## Attributes

Returned to you is the fully expanded JSON-encoded rule template with all nested templates.

# Sibling pages

* [Account hostnames](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-account-hostnames.md)
* [CP code](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-cp-code.md)
* [CP codes](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-cp-codes.md)
* [Domain](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-domain.md)
* [Domains](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-domains.md)
* [Hostname activation](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-hostname-activation.md)
* [Hostname activations](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-hostname-activations.md)
* [Hostname audit history](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-hostname-audit-history.md)
* [Hostnames](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-hostnames.md)
* [Hostnames diff](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-hostnames-diff.md)
* [Include](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-include.md)
* [Include activation](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-include-activation.md)
* [Include parents](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-include-parents.md)
* [Include rules](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-include-rules.md)
* [Includes](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-includes.md)
* [Products](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-products.md)
* [Properties](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-properties.md)
* [Property](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-property.md)
* [Property activation](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-property-activation.md)
* [Search](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-search.md)
* [Search domains](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-search-domains.md)
* [Rule formats](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-rule-formats.md)
* [Rules](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-property-rules.md)
* [Rules builder](https://techdocs.akamai.com/terraform/v9.3/docs/pm-ds-rules-builder.md)