set_​variable

Version: v2025-01-13Includes use: Yes

Behavior name: Set Variable

Modify a variable to insert into subsequent fields within the rule tree. Use this behavior to specify the pre-declared variable_name and determine from where to derive its new value.

Based on the value_source, you can either generate the value; extract it from some part of the incoming request; assign it from another variable, including a set of built-in system variables; or directly specify its text. Optionally, choose a transform function to modify the value once.

For more information, see Support for variables.

Default behavior

These samples reflect the behavior's default settings. You can use these as is in your configurations or make adjustments based on the behavior's available options.

data "akamai_property_rules_builder" "set_variable" {
  rules_v2025_02_18 {
    name     = "Set Variable"
    comments = "Modify a variable to insert into subsequent fields within the rule tree."
    behavior {
      set_variable {
        variable_name  = ""
        value_source   = "EXPRESSION"
        variable_value = ""
        transform      = "NONE"
      }
    }
  }
}
"behaviors": [
  {
    "name": "setVariable",
    "options": {
      "variablename": "",
      "valueSource": "EXPRESSION",
      "variableValue": "",
      "transform": "NONE"
    }
  }
]

Options

Option Description
variable_name
Specifies the pre-declared root name of the variable to modify. When you declare a variable name such as VARits name is preprended with PMUSER_ and accessible in a user namespace, so that you invoke it in subsequent text fields within the rule tree as {{user.PMUSER_VAR}}. In deployed XML metadata, it appears as %(PMUSER_VAR).
value_source
Determines how you want to set the value. Value is one of:
  • EXPRESSION. Specify your own string expression.
  • EXTRACT. Extract it from another value.
  • GENERATE. Generate the value.
variable_value
This directly specifies the value to assign to the variable. The expression may include a mix of static text and other variables, such as new_filename.{{builtin.AK_EXTENSION}} to embed a system variable.
extract_location
This specifies from where to get the value. Value is one of:
  • CLIENT_CERTIFICATE. Client certificate.
  • CLIENT_REQUEST_HEADER. Client request header.
  • COOKIE. Cookie.
  • EDGESCAPE. For location or network data.
  • PATH_COMPONENT_OFFSET. Substring within the URL path.
  • QUERY_STRING. A query parameter.
  • DEVICE_PROFILE. For client device attributes.
  • RESPONSE_HEADER. A response header.
  • SET_COOKIE. Cookie.
certificate_field_name
Specifies the certificate's content. Value is one of:
  • VERSION. The certificate's X509 version number.
  • SERIAL. The serial number, expressed in hex.
  • FINGERPRINT_MD5. The hex-encoded MD5 fingerprint.
  • FINGERPRINT_SHA1. The hex-encoded SHA1 fingerprint.
  • FINGERPRINT_DYN. The hex-encoded fingerprint generated based on the SIGNATURE_ALGORITHM.
  • ISSUER_DN. The distinguished name field for the certificate's issuer.
  • SUBJECT_DN. The distinguished name field for the user.
  • NOT_BEFORE. The start of the time range, expressed in YYYY/MM/DD HH:MI:SS ZONE format, where the zone is optional.
  • NOT_AFTER. The end of the time range, expressed in YYYY/MM/DD HH:MI:SS ZONE format, where the zone is optional.
  • SIGNATURE_ALGORITHM. The algorithm used to generate the certificate's signature.
  • SIGNATURE. The certificate's signature, expressed in hex.
  • CONTENTS_DER. The entire DER-encoded certificate, expressed in hex.
  • CONTENTS_PEM. The PEM-formatted certificate encoded as a single line of base64 characters.
  • CONTENTS_PEM_NO_LABELS. Same as CONTENTS_PEM but not including the certificate's header and footer.
  • COUNT. The number of client certificates received.
  • STATUS_MSG. A short message indicating the status of a certificate's validation, such as ok or missing.
  • KEY_LENGTH. The size of the key in bits.
header_name
Specifies the case-insensitive name of the HTTP header to extract.
response_header_name
Specifies the case-insensitive name of the HTTP header to extract.
set_cookie_name
Specifies the name of the origin's Set-Cookie response header.
cookie_name
Specifies the name of the cookie to extract.
location_id
Specifies the X-Akamai-Edgescape header's field name. Possible values specify basic geolocation, various geographic standards, and information about the client's network. For details on EdgeScape header fields, see the EdgeScape User Guide. Value is one of:
  • GEOREGION. Region.
  • COUNTRY_CODE. ISO-3166 country code.
  • REGION_CODE. ISO-3166 region code.
  • CITY. City.
  • DMA. Designated Market Area.
  • PMSA. Primary Metropolitan Statistical Area.
  • MSA. Metropolitan Statistical Area.
  • AREACODE. Area code.
  • COUNTY. County.
  • FIPS. Federal Information Processing System code.
  • LAT. Latitude.
  • LONG. Longitude.
  • TIMEZONE. Time zone.
  • ZIP. Zip code.
  • CONTINENT. Two-letter continent code.
  • NETWORK. Network name.
  • NETWORK_TYPE. Network type.
  • ASNUM. Autonomous System Number.
  • THROUGHPUT. Tiered throughput level.
  • BW. Tiered bandwidth level.
path_component_offset
This specifies a portion of the path. The indexing starts from 1 so a value of /path/to/nested/filename.html and an offset of 1 yields path and 3 yields nested/ Negative indexes offset from the right, so -2 also yields nested.
query_parameter_name
Specifies the name of the query parameter from which to extract the value.
generator
This specifies the type of value to generate. Value is one of:
  • HEXRAND. A random hex sequence.
  • RAND. A random number.
number_of_bytes
Specifies the number of random hex bytes to generate. Value range is 1-16.
min_random_number
Specifies the lower bound of the random number.
max_random_number
Specifies the upper bound of the random number.
transform
Specifies a function to transform the value. For more details on each transform function, see Set Variable: Operations. Value is one of:
  • NONE. No transformation.
  • ADD. Arithmetic function.
  • BASE_64_DECODE. String encoding.
  • BASE_64_ENCODE. String encoding.
  • BASE_32_DECODE. String encoding.
  • BASE_32_ENCODE. String encoding.
  • BITWISE_AND. Bitwise operation.
  • BITWISE_NOT. Bitwise operation.
  • BITWISE_OR. Bitwise operation.
  • BITWISE_XOR. Bitwise operation.
  • DECIMAL_TO_HEX. Numeric conversion.
  • DECRYPT. String encoding.
  • DIVIDE. Arithmetic function.
  • ENCRYPT. String encoding.
  • EPOCH_TO_STRING. Time format.
  • EXTRACT_PARAM. String format.
  • HASH. Integer data digest.
  • JSON_EXTRACT. JSONPath extraction from a variable.
  • HEX_TO_DECIMAL. Numeric conversion.
  • HEX_DECODE. String conversion.
  • HEX_ENCODE. String conversion.
  • HMAC. Data digest.
  • LOWER. String function.
  • MD5. Data digest.
  • MINUS. Arithmetic function, reverse sign.
  • MODULO. Arithmetic function, get remainder.
  • MULTIPLY. Arithmetic function.
  • NORMALIZE_PATH_WIN. Convert Windows paths to Unix format and remove relative path syntax.
  • REMOVE_WHITESPACE. String conversion.
  • COMPRESS_WHITESPACE. Convert whitespace characters to spaces, then compress multiple space characters into only one.
  • SHA_1. Data digest.
  • SHA_256. Data digest.
  • STRING_INDEX. String function: locate substring.
  • STRING_LENGTH. String function.
  • STRING_TO_EPOCH. Time format.
  • SUBSTITUTE. String function.
  • SUBSTRING. String function: locate index.
  • SUBTRACT. Arithmetic function.
  • TRIM. Trim surrounding whitespace in string.
  • UPPER. String function.
  • BASE_64_URL_DECODE. The same as BASE_64_DECODE except before decoding replaces + with - and / with _. If due to the encoding there are not enough characters for the algorithm, this adds = characters at the end of the string. For more information, see Output padding.
  • BASE_64_URL_ENCODE. The same as BASE_64_ENCODE except after encoding this removes trailing = characters, replacing + with - and / with _.
  • URL_DECODE. String conversion.
  • URL_ENCODE. Unicode string conversion.
  • URL_DECODE_UNI. String conversion.
  • UTC_SECONDS. Time format.
  • XML_DECODE. String conversion.
  • XML_ENCODE. String conversion.
operand_one
Specifies an additional operand.
algorithm
Specifies the algorithm to apply. Value is one of:
  • ALG_3DES. Triple DES.
  • ALG_AES128. Advanced Encryption Standard, 128 bits.
  • ALG_AES256. Advanced Encryption Standard, 256 bits.
encryption_key
Specifies the encryption hex key.
  • ALG_3DES: 48 characters
  • ALG_AES128: 32 characters
  • ALG_AES256: 64 characters
initialization_vector
Specifies a one-time number as an initialization vector.
  • ALG_3DES: 15 characters
  • ALG_AES128: 32 characters
  • ALG_AES256>: 32 characters
encryption_mode
Specifies the encryption mode. Value is one of:
  • CBC. Cipher Block Chaining.
  • ECB. Electronic Codebook.
nonce
Specifies the one-time number used for encryption.
prepend_bytes
Specifies a number of random bytes to prepend to the key.
format_string
Specifies an optional format string for the conversion, using format codes such as %m/%d/%y as specified by strftime. A blank value defaults to RFC-2616 format.
param_name
Extracts the value for the specified parameter name from a string that contains key/value pairs. Use separator below to parse them.
separator
Specifies the character that separates pairs of values within the string.
min
Specifies a minimum value for the generated integer.
max
Specifies a maximum value for the generated integer.
hmac_key
Specifies the secret to use in generating the base64-encoded digest.
hmac_algorithm
Specifies the algorithm to use to generate the base64-encoded digest. Value is one of:
  • SHA1
  • SHA256
  • MD5
ip_version
Specifies which IP version a subnet mask generates. Value is one of:
  • IPV4
  • IPV6
ipv6Prefix
Specifies the prefix of the IPV6 address. Value range is 0-128.
ipv4Prefix
Specifies the prefix of the IPV4 address. Value range is 0-32.
sub_string
Specifies a substring for which the returned value represents a zero-based offset of where it appears in the original string, or -1 if there's no match.
regex
Specifies the regular expression pattern (PCRE) to match the value.
replacement
Specifies the replacement string. Reinsert grouped items from the match into the replacement using a $ followed by a number. For example, $1
case_sensitive
Enabling this makes all matches case sensitive.
global_substitution
Replaces all matches in the string, not just the first.
start_index
Specifies the zero-based character offset at the start of the substring. Negative indexes specify the offset from the end of the string.
end_index
Specifies the zero-based character offset at the end of the substring, without including the character at that index position. Negative indexes specify the offset from the end of the string.
except_chars
Specifies characters not to encode, possibly overriding the default set.
force_chars
Specifies characters to encode, possibly overriding the default set.
device_profile
Specifies the client device attribute. Possible values specify information about the client device, including device type, size and browser. Value is one of:
  • IS_MOBILE. Basic device attributes, boolean.
  • IS_TABLET. Basic device attributes, boolean.
  • IS_WIRELESS_DEVICE. Basic device attributes, boolean.
  • PHYSICAL_SCREEN_HEIGHT. Device screen size in millimeters.
  • PHYSICAL_SCREEN_WIDTH. Device screen size in millimeters.
  • RESOLUTION_HEIGHT. Device screen size in pixels.
  • RESOLUTION_WIDTH. Device screen size in pixels.
  • VIEWPORT_WIDTH. Device viewport size in millimeters.
  • BRAND_NAME. Basic device attributes, string values.
  • DEVICE_OS. Basic device attributes, string values.
  • DEVICE_OS_VERSION. Basic device attributes, string values.
  • DUAL_ORIENTATION. Whether the display adapts to portrait/landscape orientation.
  • MAX_IMAGE_HEIGHT. Maximum image size that can be displayed, in pixels.
  • MAX_IMAGE_WIDTH. Maximum image size that can be displayed, in pixels.
  • MOBILE_BROWSER. Basic device attributes, string values.
  • MOBILE_BROWSER_VERSION. Basic device attributes, string values.
  • PDF_SUPPORT. Device support capabilities, boolean.
  • COOKIE_SUPPORT. Device support capabilities, boolean.
For more information, see Device Characterization.