[IAM drift] Resources in `DELETE_REQUESTED` state should be filtered out
- Dominant language
- Go
- Stars
- 26
- Forks
- 7
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
### TL;DR
Context for https://github.com/abcxyz/guardian/blob/main/pkg/commands/drift/drift.go#L194.
Currently, `asset.SearchAllIamPolicies` will include IAM policies bound to resources that are soft-deleted (state=`DELETE_REQUESTED`) and these are identified as drift. These are false-positives and should be filtered out.
**Initial approach**
1. Get all soft-deleted projects/folders with `asset.SearchAllResources`
2. Exclude them using a query for `asset.SearchAllIamPolicies`.
However, I found that `asset.SearchAllIamPolicies` does not support negated queries, which makes it infeasible to exclude projects/folders in `DELETE_REQUESTED` state from the API response.
**A hacky alternative**
1. `SearchAllResources` for folders/projects in `state:DELETE_REQUESTED`
2. Append these resources to the driftignore hierarchy graph so they will be filtered out using the driftignore approach
While the alternative could work, the best solution is if we can apply the filter in the `SearchAllIamPolicies` request, which doesn't seem to be possible at the moment.
### Expected behavior
_No response_
### Observed behavior
_No response_
### Environment Details
All
### Additional information
_No response_
Contributor guide
Research direction
The issue is in pkg/commands/drift/drift.go line 194, where asset.SearchAllIamPolicies includes soft-deleted resources. First, understand how asset.SearchAllResources and asset.SearchAllIamPolicies work by reading the code around that line and the asset package. Then, explore the driftignore hierarchy graph to see how resources are filtered. The goal is to exclude resources in DELETE_REQUESTED state from drift detection, either by modifying the query or by adding them to the driftignore graph.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100