Skip to content

Commit c479e34

Browse files
authored
Merge pull request #101 from ekristen/feature-flags
feat: feature flags
2 parents 6068547 + 1f9608a commit c479e34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+262
-91
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ linters:
3838
- bodyclose
3939
- dogsled
4040
- errcheck
41-
- exportloopref
41+
- copyloopvar
4242
- funlen
4343
- goconst
4444
- gocritic

docs/cli-experimental.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,53 @@
22

33
## Overview
44

5-
These are the experimental features hidden behind feature flags that are currently available in aws-nuke. They are all
5+
These are the experimental features hidden behind feature flags that are currently available in azure-nuke. They are all
66
disabled by default. These are switches that changes the actual behavior of the tool itself. Changing the behavior of
77
a resource is done via resource settings.
88

99
!!! note
10-
The original tool had configuration options called `feature-flags` which were used to enable/disable certain
11-
behaviors with resources, those are now called settings and `feature-flags` have been deprecated in the config.
10+
The original tool had configuration options called `feature-flags` which were used to enable/disable certain
11+
behaviors with resources, those are now called settings and `feature-flags` have been deprecated in the config.
1212

1313
## Usage
1414

1515
```console
16-
azure-nuke run --feature-flag "some-feature"
16+
azure-nuke run --feature-flag "wait-on-dependencies"
1717
```
1818

1919
**Note:** other CLI arguments are omitted for brevity.
2020

2121
## Available Feature Flags
2222

23-
No available features at this time.
23+
- `filter-groups` - This feature flag will cause azure-nuke to filter based on a grouping method which allows for AND'ing
24+
filters together.
25+
- `wait-on-dependencies` - This feature flag will cause azure-nuke to wait for all resource type dependencies to be
26+
deleted before deleting the next resource type.
27+
28+
### wait-on-dependencies
29+
30+
This feature flag will cause azure-nuke to wait for all resource type dependencies to be deleted before deleting the next
31+
resource type. This is useful for resources that have dependencies on other resources. For example, an IAM Role that has
32+
an attached policy.
33+
34+
The problem is that if you delete the IAM Role first, it will fail because it has a dependency on the policy.
35+
36+
This feature flag will cause azure-nuke to wait for all resources of a given type to be deleted before deleting the next
37+
resource type. This will reduce the number of errors and unnecessary API calls.
38+
39+
### filter-groups
40+
41+
This feature flag will cause azure-nuke to filter resources based on a group method. This is useful when filters need
42+
to be AND'd together. For example, if you want to delete all resources that are tagged with `env:dev` and `namespace:test`
43+
you can use the following filter group:
44+
45+
```yaml
46+
filters:
47+
ResourceType:
48+
- property: tag:env
49+
value: dev
50+
group: group1
51+
- property: tag:namespace
52+
value: test
53+
group: group2
54+
```

docs/config-filtering.md

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
!!! warning
22
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
44
bugs, no matter how careful we review new code.
55

66
# Filtering
@@ -23,12 +23,12 @@ a resource does NOT have any filters defined, the `__global__` ones will still b
2323

2424
### Example
2525

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
2727
a specific instance by its `id`. When the `EC2Instance` resource is processed, it will have both filters applied. These
2828

2929
```yaml
3030
__global__:
31-
- property: tag:aws-nuke
31+
- property: tag:azure-nuke
3232
value: "ignore"
3333

3434
EC2Instance:
@@ -40,10 +40,68 @@ This will ultimately render as the following filters for the `EC2Instance` resou
4040
```yaml
4141
EC2Instance:
4242
- "i-01b489457a60298dd"
43-
- property: tag:aws-nuke
43+
- property: tag:azure-nuke
4444
value: "ignore"
4545
```
4646

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+
47105
## Types
48106

49107
The following are comparisons that you can use to filter resources. These are used in the configuration file.
@@ -143,7 +201,7 @@ EC2Image:
143201
## Properties
144202

145203
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
147205
function that returns a string representation of the resource.
148206

149207
Some resources support filtering via properties. When a resource support these properties, they will be listed in
@@ -175,7 +233,7 @@ ResourceGroup:
175233
invert: true
176234
```
177235

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*
179237
internally takes every resource and applies every filter on it. If a filter matches, it marks the node as filtered.
180238

181239
## Example
@@ -194,12 +252,12 @@ ResourceGroup:
194252

195253
It is possible to filter this is important for not deleting the current user for example or for resources like S3
196254
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`
198256
for an EC2 instance).
199257

200258
!!! 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
203261
always a possibility to introduce new bugs, no matter how careful we review new code.**
204262

205263
The filters are part of the account-specific configuration and are grouped by resource types. This is an example of a

docs/features/filter-groups.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Filter Groups
2+
3+
!!! important
4+
This feature is experimental and is disabled by default. To enable it, use the `--feature-flag "filter-groups"` CLI argument.
5+
6+
Filter groups allow you to filter resources based on a grouping method which allows for AND'ing filters together. By
7+
default, all filters belong to the same group, but you can specify a group name to group filters together.
8+
9+
All filters within a group are OR'd together, and all groups are AND'd together.
10+
11+
[Full Documentation](../config-filtering.md#filter-groups)

docs/resources/app-service-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
## Properties
99

10-
- **`ResourceGroup`**: No description provided
10+
- **`BaseResource`**: No description provided
1111
- **`Name`**: No description provided

docs/resources/application-certificate.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
## Properties
99

10+
- **`BaseResource`**: No description provided
1011
- **`ID`**: No description provided
1112
- **`Name`**: No description provided
1213
- **`AppID`**: No description provided

docs/resources/application-federated-credential.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
## Properties
99

10+
- **`BaseResource`**: No description provided
1011
- **`ID`**: No description provided
1112
- **`Name`**: No description provided
1213
- **`AppID`**: No description provided
13-
- **`AppUniqueName`**: No description provided
14+
- **`DisplayName`**: No description provided
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Application Gateway
2+
3+
## Details
4+
5+
- **Type:** `ApplicationGateway`
6+
- **Scope:** resource-group
7+
8+
## Properties
9+
10+
- **`BaseResource`**: No description provided
11+
- **`ID`**: No description provided
12+
- **`Name`**: No description provided

docs/resources/application-secret.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
## Properties
99

10-
- **`ID`**: No description provided
11-
- **`Name`**: No description provided
12-
- **`AppID`**: No description provided
13-
- **`AppName`**: No description provided
10+
- **`AppID`**: The unique ID of the Application to which the secret belongs
11+
- **`AppName`**: The display name of the Application to which the secret belongs
12+
- **`BaseResource`**: No description provided
13+
- **`KeyID`**: The unique ID of the Application Secret Key
14+
- **`Name`**: The display name of the Application Secret

docs/resources/application.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
## Properties
99

10+
- **`BaseResource`**: No description provided
1011
- **`ID`**: No description provided
1112
- **`Name`**: No description provided

0 commit comments

Comments
 (0)