Configuration Reference
This is the Traffic Policy configuration reference for this action.Supported Phases
on_http_request
, on_http_response
, on_tcp_connect
Type
set-vars
Configuration Fields
List of maps that have a key of string and a value of any valid CEL type
Each map must be of exactly size
1
, and represents one variable where the
key is the name of the variable:Behavior
Theset-vars
action allows you to define your own global variables to be used in future actions or expressions, like this:
set-vars
action, you can access them through CEL Interpolation or anywhere else that CEL is supported, like expressions.
You can use any valid CEL type as a variable value, including strings, booleans, doubles, null, maps, and lists.
CEL Interpolation
Variables also support CEL interpolation (${<expression>}
) in values,
enabling you to create dynamic values and types:
"${vars.<name>}"
will resolve to the evaluated type.
Strings that contain CEL-interpolated substrings within them such as sample ${conn.tls.client.pem} here
will convert all CEL-interpolated substrings to strings
Scoping
Variables you define in theset-vars
action are scoped to the Traffic Policy
and are not accessible outside of it.
Variables defined in each of the three phases
(on_http_request
, on_http_response
, on_tcp_connect
) are scoped to that
phase, and cannot be accessed in other phases.
Referencing other variables and macros
CEL-interpolated strings may reference all other variables and macros available to traffic policies. This also includes variables previously defined in the same or previousset-vars
actions. This allows for powerful dynamic behavior
and customization of your Traffic Policy.
Examples
Basic Example
The following Traffic Policy configuration is an example configuration of theset-vars
action.
Example Traffic Policy Document
CEL Interpolation Example
The following Traffic Policy configuration is an example of using CEL-interpolation with theset-vars
action.
Example Traffic Policy Document
Setting Vars based on Previous Vars Example
The following Traffic Policy configuration is an example of setting vars based on previous vars with theset-vars
action.
Variables are determined in the order in which they are listed in the configuration list.