Creating Conditions
For an introduction, see What are Conditions.
A conditional expression includes at least one comparison, which compares two arguments by using a comparison operator (equals, greater than, and so on). Each argument in a comparison can be a literal value or you can use functions like GetParam
. A comparison evaluates to true or false.
A filter in a conditional expression combines the results of two or more comparisons. A filter can evaluate if any, all, or none of the comparisons are true.
The following image depicts a filter that contains two comparisons:
For more complex conditional expressions, you can also add filters to a filter.
Defining Global Conditions
If you need to use the same conditional expression at multiple locations in your Oracle Cloud Stack template, create a condition at the template level. You can then refer to these global conditions throughout the template.
When editing an existing condition:
-
Click Add condition expression
to add filters or comparisons.
-
Click Delete condition expression
to delete filters or comparisons.
Adding a Condition to a Resource
Assign a global condition to a resource in your Oracle Cloud Stack template.
If this condition evaluates to true, the resource will be created as part of the stack. If it evaluates to false the resource (and any resources on which it depends) will not be created.
As an alternative to using the canvas, you can also create, assign, and remove conditions when editing a resource’s configuration.
Adding a Condition to a Resource Parameter
Use global conditions to dynamically change a resource’s configuration in an Oracle Cloud Stack template.
For example, you can set a resource’s computeShape
to the value oc3
if a condition is true, or to the value oc4
if the condition is false.
Tip:
A YAML sequence can also be expressed with the following syntax:'Fn::If':
- conditionName
- trueValue
- falseValue
Adding a Condition to a Template Parameter
Assign a global condition to a parameter or parameter group in your Oracle Cloud Stack template.
If the condition evaluates to false, the parameter or group is hidden in the Oracle Cloud Stack console when a user creates a stack from this template. If it evaluates to true, the parameter or group is displayed to the user. These conditions are dynamically reevaluated each time the user modifies the value of a template parameter.
- Access the Oracle Cloud Stack console, and then edit your template.
- To the left of Parameters or Parameter Groups, click
.
- To the right of the parameter or group that you want to modify, click Edit
.
- From the Conditions field, select an existing condition.
- Click Apply Changes.
- Click Save the current template
.