You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Filters.md
+28-10Lines changed: 28 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,20 +3,42 @@
3
3
Data sources that return lists of resources support filtering semantics.
4
4
To employ a filter include this block in your data source definition:
5
5
6
-
```
6
+
```hcl
7
7
filter {
8
8
name = ""
9
9
values = [""]
10
10
}
11
11
```
12
12
13
-
The `name` value corresponds to the property name to filter with
14
-
and the `values` lists can contain one or more values filter with.
13
+
The `name` value corresponds to the qualified property name to filter with
14
+
and the `values` lists can contain one or more values filter with.
15
+
16
+
Nested Properties and map elements can be addressed by qualifying the property name with parent property name
17
+
Example r1 will give all the instances which have `source_type` image
18
+
Example r2 will give all the instances which contain a defined tag with value "42" for key `CostCenter` in the namespace `Operations`
19
+
```hcl
20
+
data "oci_core_instances" "r1" {
21
+
...
22
+
filter {
23
+
name = "source_details.source_type"
24
+
value = ["image"]
25
+
}
26
+
}
27
+
28
+
data "oci_core_instances" "r2" {
29
+
...
30
+
filter {
31
+
name = "defined_tags.Operations.CostCenter"
32
+
value = ["42"]
33
+
}
34
+
}
35
+
36
+
```
15
37
16
38
Multiple `values` work as an **OR** type filter. In the shape
17
39
example below, the resulting data source would contain both VM
18
40
shapes _Standard 1.1_ and _Standard 1.2_:
19
-
```
41
+
```hcl
20
42
data "oci_core_shape" "t" {
21
43
...
22
44
filter {
@@ -28,7 +50,7 @@ data "oci_core_shape" "t" {
28
50
29
51
Multiple filters blocks can be composed to form **AND** type comparisons. The example below will return a data source containing
30
52
_running instances_ in the _first AD_ of a region:
31
-
```
53
+
```hcl
32
54
data "oci_core_instances" "s" {
33
55
...
34
56
filter {
@@ -52,8 +74,4 @@ expression special characters need to be escaped with another slash,
52
74
shown above as the first `\` before `\w` in `"\\w*-AD-1"`.
53
75
54
76
### Limitations
55
-
Currently filters can only target top level attributes of a
56
-
resource (or top level arrays of strings).
57
-
58
-
Drilling into properties of structured objects or lists of structured objects is not currently
59
-
supported. If these properties are targeted no results will be returned from the datasource.
77
+
Drilling into lists of structured objects is not currently supported. If these properties are targeted no results will be returned from the datasource.
0 commit comments