As an alternative to the simple conditions list in Cloud Assembly, the advanced editor lets you assemble more complex criteria expressions to control when the action is available.
When creating a new resource action, select Requires condition and Use advanced editor. Then, enter the criteria expression that you want.
The expression is a clause or list of clauses, each of which is in key-operator-value format. The preceding figure shows criteria where the target must be powered on and present.
Clauses
Clause | Description | Example |
---|---|---|
and | All subclauses need to be true for the expression result to be true. | Evaluate as true only when both properties.powerState is ON and syncStatus is not MISSING. matchExpression: - and: - key: properties.powerState operator: eq value: ON - key: syncStatus operator: notEq value: MISSING |
or | One or more of the subclauses need to be true for the expression result to be true. | Evaluate as true whether properties.powerState is ON or OFF. matchExpression: - or: - key: properties.powerState operator: eq value: ON - key: properties.powerState operator: eq value: OFF |
Operators
Operator | Description | Example |
---|---|---|
eq | Equal. Look for an exact match. | Evaluate as true when properties.powerState is ON. matchExpression: - and: - key: properties.powerState operator: eq value: ON |
notEq | Not equal. Avoid an exact match. | Evaluate as true when properties.powerState is not OFF. matchExpression: - and: - key: properties.powerState operator: notEq value: OFF |
hasAny | Look for a match in a collection of objects. | Evaluate as true when the storage.disks array includes a 100 IOPS EBS object. matchExpression: - key: storage.disks operator: hasAny value: matchExpression: - and: - key: iops operator: eq value: 100 - key: service operator: eq value: ebs |
in | Look for a match in a set of values. | Evaluate as true when properties.powerState is either OFF or SUSPEND. matchExpression: - and: - key: properties.powerState operator: in value: OFF, SUSPEND |
notIn | Avoid matching a set of values. | Evaluate as true when properties.powerState is neither OFF nor SUSPEND. matchExpression: - and: - key: properties.powerState operator: notIn value: OFF, SUSPEND |
greaterThan | Look for a match over a given threshold. Only applies to numeric values. | Evaluate as true when the first object in the storage.disks array has IOPS over 50. matchExpression: - and: - key: storage.disks[0].iops operator: greaterThan value: 50 |
lessThan | Look for a match under a given threshold. Only applies to numeric values. | Evaluate as true when the first object in the storage.disks array has IOPS under 200. matchExpression: - and: - key: storage.disks[0].iops operator: lessThan value: 200 |
greaterThanEquals | Look for a match at or above a given threshold. Only applies to numeric values. | Evaluate as true when the first object in the storage.disks array has IOPS of 100 or higher. matchExpression: - and: - key: storage.disks[0].iops operator: greaterThanEquals value: 100 |
lessThanEquals | Look for a match at or below a given threshold. Only applies to numeric values. | Evaluate as true when the first object in the storage.disks array has IOPS of 100 or lower. matchExpression: - and: - key: storage.disks[0].iops operator: lessThanEquals value: 100 |
matchesRegex | Use a regular expression to look for a match. | Evaluate as true when the properties.zone is us-east-1a or us-east-1c. matchExpression: - and: - key: properties.zone operator: matchesRegex value: (us-east-1)+(a|c){1,2} |
Examples
The following criteria expression evaluates as true when properties.tags includes a tag of key key1
and value value1
.
The outer expression uses hasAny
because properties.tags is an array, and you want to evaluate as true whenever key1=value1 appears in any of the key-value pairs in the array.
In the inner expression, there are two clauses, one for the key field and one for the value field. The properties.tags array holds key-value tagging pairs, and you need to match both the key and value fields.
matchExpression: - key: properties.tags operator: hasAny value: matchExpression: - and: - key: key operator: eq value: key1 - key: value operator: eq value: value1
The following criteria expression is similar to the previous example, but now evaluates as true whenever properties.tags includes either a tag of key1=value1 or key2=value2.
matchExpression: - or: - key: properties.tags operator: hasAny value: matchExpression: - and: - key: key operator: eq value: key1 - key: value operator: eq value: value1 - key: properties.tags operator: hasAny value: matchExpression: - and: - key: key operator: eq value: key2 - key: value operator: eq value: value2