Define or update global variables in a Traffic Policy’s runtime context.
The Set Vars action is used to define or update global variables in a
Traffic Policy’s runtime context. Subsequent actions or expressions can
reference these variables for conditional logic through expressions or
dynamic interpolation.
After being defined through the 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-interpolated strings that are exactly of the form "${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
Variables you define in the set-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.
CEL-interpolated strings may reference all other variables and macros available
to Traffic Policies. This also includes variables previously defined in the
same or previous set-vars actions. This allows for powerful dynamic behavior
and customization of your Traffic Policy.
This is a Non-terminating action. It does not return a response, and will allow Traffic Policy processing to continue to the next Action in the chain. All Cloud Endpoint Traffic Policies must end with a terminating action. This requirement does not apply to Agent Endpoints.
The following Traffic Policy configuration is an example of setting vars based on previous vars with the set-vars action.Variables are determined in the order in which they are listed in the configuration list.