You're viewing OCI IAM documentation for new tenancies in regions that have been updated to use identity domains.

Writing Matching Rules to Define Dynamic Groups

Matching rules define the resources that belong to a dynamic group.

In the Console, you can either enter the rule manually in the provided text box, or you can use the rule builder. The rule builder lets you make selections and entries in a dialog, then writes the rule for you, based on your entries. The rule builder supports the instance and compartment variables. To write a rule based on other variables, enter it manually.

You can define the members of the dynamic group based on the following:

  • compartment OCID
  • instance OCID (for instances) or resource OCID (for other resources)
  • resource type
  • tag namespace and tag key - include (or exclude) instances tagged with a specific tag namespace and tag key. All tag values are included. For example, include all instances tagged the with tag namespace department and the tag key operations.
  • tag namespace, tag key, and tag value - include (or exclude) instances tagged with a specific value for the tag namespace and tag key. For example include all instances tagged with the tag namespace department and the tag key operations and with the value '45'.

A matching rule has the following syntax:

For a single condition:

variable {{=}} | !='value'

For several conditions:

any|all {<condition>,<condition>,...}

Supported variables are:

For instances, you can use:

  • instance.compartment.id - the OCID of the compartment where the instance resides
  • instance.id - the OCID of the instance

For all supported resource types, you can use:

  • resource.id - the OCID of the resource
  • resource.compartment.id - the OCID of the compartment where the resource resides
  • resource.type - the type of resource. The resource type is shown in the resource's OCID. For example:
    • a domain's OCID has the format ocid1.domain..., so specify domain as the resource.type.
    • a function's OCID has the format ocid1.fnfunction..., so specify fnfunction as the resource.type
    • an API gateway's OCID has the format ocid1.apigateway... , so specify apigateway as the resource.type
  • tag.<tagnamespace>.<tagkey>.value - the tag namespace and tag key. For example, tag.department.operations.value.
  • tag.<tagnamespace>.<tagkey>.value = '<tagvalue>' - the tag namespace, tag key, and tag value. For example, tag.department.operations.value = '45'
Note

IAM policies don't support free-form tags. See Understanding Free-form Tags.

Examples: