1
1
!!! warning
2
2
Filtering is a powerful tool, but it is also a double-edged sword. It is easy to make mistakes in the filter
3
- configuration. Also, since aws -nuke is in continuous development, there is always a possibility to introduce new
3
+ configuration. Also, since azure -nuke is in continuous development, there is always a possibility to introduce new
4
4
bugs, no matter how careful we review new code.
5
5
6
6
# Filtering
@@ -23,12 +23,12 @@ a resource does NOT have any filters defined, the `__global__` ones will still b
23
23
24
24
### Example
25
25
26
- In this example, we are ignoring all resources that have the tag ` aws -nuke` set to ` ignore ` . Additionally filtering
26
+ In this example, we are ignoring all resources that have the tag ` azure -nuke` set to ` ignore ` . Additionally filtering
27
27
a specific instance by its ` id ` . When the ` EC2Instance ` resource is processed, it will have both filters applied. These
28
28
29
29
``` yaml
30
30
__global__ :
31
- - property : tag:aws -nuke
31
+ - property : tag:azure -nuke
32
32
value : " ignore"
33
33
34
34
EC2Instance :
@@ -40,10 +40,68 @@ This will ultimately render as the following filters for the `EC2Instance` resou
40
40
` ` ` yaml
41
41
EC2Instance:
42
42
- "i-01b489457a60298dd"
43
- - property: tag:aws -nuke
43
+ - property: tag:azure -nuke
44
44
value: "ignore"
45
45
` ` `
46
46
47
+ # # Filter Groups
48
+
49
+ !!! important
50
+ Filter groups are an experimental feature and are disabled by default. To enable filter groups, use the
51
+ ` --feature-flag filter-groups` flag.
52
+
53
+ Filter groups are used to group filters together. This is useful when filters need to be AND'd together. For example,
54
+ if you want to delete all resources that are tagged with `env:dev` and `namespace:test` you can use the following filter
55
+ group :
56
+
57
+ ` ` ` yaml
58
+ presets:
59
+ example:
60
+ filters:
61
+ ResourceType:
62
+ - property: tag:env
63
+ value: dev
64
+ group: group1
65
+ - property: tag:namespace
66
+ value: test
67
+ group: group2
68
+ ` ` `
69
+
70
+ In this example, the `group1` and `group2` filters are AND'd together. This means that a resource must match both filters
71
+ to be excluded from deletion.
72
+
73
+ Only a single filter in a group is required to match. This means that if a resource matches any filter in a group it will
74
+ count as a match for the group.
75
+
76
+ # ## Example
77
+
78
+ In this example, we are ignoring all resources that have the tag `azure-nuke` set to `ignore`. Additionally filtering
79
+ a specific instance by its `id`. When the `EC2Instance` resource is processed, it will have both filters applied. These
80
+
81
+ ` ` ` yaml
82
+ presets:
83
+ example:
84
+ filters:
85
+ __global__:
86
+ - property: tag:azure-nuke
87
+ value: "ignore"
88
+ EC2Instance:
89
+ - "i-01b489457a60298dd"
90
+ ` ` `
91
+
92
+ This will ultimately render as the following filters for the `EC2Instance` resource :
93
+
94
+ ` ` ` yaml
95
+ presets:
96
+ example:
97
+ filters:
98
+ EC2Instance:
99
+ - "i-01b489457a60298dd"
100
+ - property: tag:azure-nuke
101
+ value: "ignore"
102
+ ` ` `
103
+
104
+
47
105
# # Types
48
106
49
107
The following are comparisons that you can use to filter resources. These are used in the configuration file.
@@ -143,7 +201,7 @@ EC2Image:
143
201
# # Properties
144
202
145
203
By default, when writing a filter if you do not specify a property, it will use the `Name` property. However, resources
146
- that do no support Properties, aws -nuke will fall back to what is called the `Legacy String`, it's essentially a
204
+ that do no support Properties, azure -nuke will fall back to what is called the `Legacy String`, it's essentially a
147
205
function that returns a string representation of the resource.
148
206
149
207
Some resources support filtering via properties. When a resource support these properties, they will be listed in
@@ -175,7 +233,7 @@ ResourceGroup:
175
233
invert: true
176
234
` ` `
177
235
178
- In this case *any* ResourceGroup ***but*** the ones called "foo" will be filtered. Be aware that *aws -nuke*
236
+ In this case *any* ResourceGroup ***but*** the ones called "foo" will be filtered. Be aware that *azure -nuke*
179
237
internally takes every resource and applies every filter on it. If a filter matches, it marks the node as filtered.
180
238
181
239
# # Example
@@ -194,12 +252,12 @@ ResourceGroup:
194
252
195
253
It is possible to filter this is important for not deleting the current user for example or for resources like S3
196
254
Buckets which have a globally shared namespace and might be hard to recreate. Currently, the filtering is based on
197
- the resource identifier. The identifier will be printed as the first step of *aws -nuke* (eg `i-01b489457a60298dd`
255
+ the resource identifier. The identifier will be printed as the first step of *azure -nuke* (eg `i-01b489457a60298dd`
198
256
for an EC2 instance).
199
257
200
258
!!! warning
201
- **Even with filters you should not run aws -nuke on any AWS account, where you cannot afford to lose all resources.
202
- It is easy to make mistakes in the filter configuration. Also, since aws -nuke is in continuous development, there is
259
+ **Even with filters you should not run azure -nuke on any AWS account, where you cannot afford to lose all resources.
260
+ It is easy to make mistakes in the filter configuration. Also, since azure -nuke is in continuous development, there is
203
261
always a possibility to introduce new bugs, no matter how careful we review new code.**
204
262
205
263
The filters are part of the account-specific configuration and are grouped by resource types. This is an example of a
0 commit comments