Language: Parameters
Sentinel allows a policy author to supply parameters to help facilitate policy reuse and ensure sensitive values do not need to be hard-coded in a policy.
Parameters are supplied by using the param
keyword, followed by an identifier.
A default value can also be supplied by using the default
keyword.
Once declared, parameters can be used like any other variable, including being re-assigned.
Variable Descriptions
You can supply a description to a parameter by adding a comment at the top of it. This value can be communicated to a specific implementation of Sentinel to provide information about what the parameter is for during configuration.
Supplying Parameter Values Using the Sentinel CLI
In a production implementation, supplying parameters to a policy is an implementation-specific detail - see the documentation for your particular implementation for details.
Using the Sentinel CLI, you can supply parameters one of four ways.
Supplying Parameter Values Using the Configuration File
You can supply parameters using the
param
section of the
configuration file.
This method works for both sentinel apply
and sentinel test
.
In addition to the above, you can supply targeted parameters to each policy block in the configuration file.
Supplying Parameter Values Using the Environment
NOTE: This method of supplying parameters is only supported by sentinel apply
.
You can supply a value using environment variables - prefix the parameter with
SENTINEL_PARAM_
, using the name of the parameter to supply.
Supplying Parameter Values Using CLI Arguments
NOTE: This method of supplying parameters is only supported by sentinel apply
.
You can also use the -param
CLI argument to supply parameter in a key=value
pair.
Interactive CLI Prompting
NOTE: This method of supplying parameters is only supported by sentinel apply
.
If a required value has not been supplied when a policy is run with sentinel apply
, it will be prompted for, along with its description:
CLI Value Format
NOTE: This section contains details for the parameter features supported by sentinel apply
.
The CLI takes either strings, or JSON numbers, arrays, or maps. If you need a literal string value, quote the value.
NOTE: Boolean values are not supported by this method.