Appendix D: Resource selection - Ops Automator

Appendix D: Resource selection

Ops Automator uses a custom tag key (name) to identify resources that will receive automated actions. The default tag key is OpsAutomatorTaskList, but you can modify it during initial configuration of the solution’s AWS CloudFormation template. The value of the OpsAutomatorTaskList tag contains a comma-separated list of tasks you want the solution to perform on that resource. For more information, refer to Step 5.

Or, you can use a tag filter expression to specify the tasks you want to perform on resources. The expression overwrites the selection of resources based on the values in the OpsAutomatorTaskList tag key. A tag filter expression enables a more granular selection of resources. They have the format <tag-name>[=<tag-value>]. The tag names and values can contain wildcards, regular expressions, and Boolean operators. For example, a tag filter with a value of * will select all resources. To use a regular expression, the tag name or value must start with \.

Tag filter format Description
* Any tagged resource.
Note

For actions that can delete or terminate resources, you cannot use “*” as the name of the tag in the filter.

A* Tag keys that start with “A”.
*A* Tag keys that contain “A”.
*A Tag keys that end with “A”.
\.*\d$ Tag keys that end with a digit.
A=B Tag keys “A” with value “B”.
A=B* Tag keys “A” with a value that starts with “B”.
*=B Any tag with a value “B”.
*=B* Any tag with a value that starts with “B”.
*=\.*\d$ Any tag with a value that ends with a digit.
A=B,C=D Tag keys “A” with value “B” or tag keys “C” with a value “D”.

A tag filter expression can also contain multiple filters combined using logical operators. Use & for AND, | for OR, or ! for NOT. You can also group filters using parentheses.

Expression Description
A=*&B=* Tags “A” and “B” with any value.
A=*|B=* Tag “A” or “B” with any value.
((A=*&B=*)|C=*) Tags “A” and “B”, or tag “C” with any value.
!A=* Not tag “A”.
A=!B Tag “A” not having value “B”.
(!A=*)&(C=!D) Not tag “A” and tag “C” not having value “D”.

The following table gives examples of different tag filters and the resulting Ops Automator action.

Tag filter Ops Automator Action
Owner=DBAdmin Perform the task on resources with the Owner tag key with a value of DBAdmin.
Owner Perform the task on resources with the Owner tag key with any value.
*=DBAdmin Perform the task on resources with any tag key with a value of DBAdmin.
*test Perform the task on resources with a tag key that ends with test.
test* Perform the task on resources with a tag key that starts with test.
*=*test Perform the task on resources with any tag key with a value that ends with test.
*=test* Perform the task on resources with any tag key with a value that starts with test.
(Owner=DBAdmin)&(Stack=Test) Perform the task on resources with the Owner tag key with a value of DBAdmin and resources with the Stack tag key with a value of Test.
(Owner=DBAdmin)|(Stack=Test) Perform the task on resources with the Owner tag key with a value of DBAdmin or resources with the Stack tag key with a value of Test.
(Owner=DBAdmin)&(Stack=!Test) Perform the task on resources with the Owner tag key with a value of DBAdmin or resources with the Stack tag key with a value that is not Test.