Skip to content

Commit 22023cc

Browse files
committed
Updating filters documentation for nested structures and maps
1 parent 89011a4 commit 22023cc

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

docs/Filters.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,42 @@
33
Data sources that return lists of resources support filtering semantics.
44
To employ a filter include this block in your data source definition:
55

6-
```
6+
```hcl
77
filter {
88
name = ""
99
values = [""]
1010
}
1111
```
1212

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+
```
1537

1638
Multiple `values` work as an **OR** type filter. In the shape
1739
example below, the resulting data source would contain both VM
1840
shapes _Standard 1.1_ and _Standard 1.2_:
19-
```
41+
```hcl
2042
data "oci_core_shape" "t" {
2143
...
2244
filter {
@@ -28,7 +50,7 @@ data "oci_core_shape" "t" {
2850

2951
Multiple filters blocks can be composed to form **AND** type comparisons. The example below will return a data source containing
3052
_running instances_ in the _first AD_ of a region:
31-
```
53+
```hcl
3254
data "oci_core_instances" "s" {
3355
...
3456
filter {
@@ -52,8 +74,4 @@ expression special characters need to be escaped with another slash,
5274
shown above as the first `\` before `\w` in `"\\w*-AD-1"`.
5375

5476
### 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

Comments
 (0)