Sub topic 8
Archive rules for intended access
This chapter assumes you can read IAM policy JSON, run the AWS CLI, and already have an external access analyzer with at least one finding. Findings, statuses and filters were covered in the previous chapter.
Why archive rules exist
An external access analyzer reports every resource shared outside your zone of trust. Some of that sharing is intended. A bucket shared with a partner account, or a role trusted by a central tooling account, will appear as a finding every time the analyzer scans it.
If you leave these findings active, the list fills with items you have already reviewed. Real problems become hard to see. An archive rule fixes this. It is a saved filter on an analyzer. Any finding that matches it, now or in the future, is archived automatically.
An archived finding is not deleted. It stays in the analyzer with the status ARCHIVED, and you can still list it and review it. The analyzer also keeps monitoring the resource. If the access changes so that it no longer matches the rule, the finding becomes active again.
Creating a rule
An archive rule has a name and a filter. The filter uses the same criteria as finding queries, such as resource, principal.AWS, resourceType or isPublic.
aws accessanalyzer create-archive-rule \
--analyzer-name account-external \
--rule-name known-partner-bucket \
--filter '{"resource":{"eq":["arn:aws:s3:::example-partner-share"]}}'This rule archives findings for one bucket. After you create it, Access Analyzer applies it to existing findings and to new ones.
A rule that matches only on resource archives any access to that bucket, including access you did not intend. If the bucket's policy later gains "Principal": "*", the new public finding still matches the resource filter and is archived silently. Narrow the rule with a second criterion:
aws accessanalyzer create-archive-rule \
--analyzer-name account-external \
--rule-name partner-bucket-partner-account-only \
--filter '{
"resource":{"eq":["arn:aws:s3:::example-partner-share"]},
"principal.AWS":{"eq":["444455556666"]}
}'Now only access granted to account 444455556666 is archived. A change that grants access to anyone else produces a new active finding.
Choosing filters
Use the narrowest filter that describes the intent.
| Filter | What it archives | Risk |
|---|---|---|
| `resource` only | All external access to one resource | Hides later changes to that resource |
| `resource` plus `principal.AWS` | Access to one resource by one account | Low |
| `principal.AWS` only | Everything shared with one account | Hides new resources shared with it |
| `isPublic` equals true | All public findings | Hides real exposure; avoid |
How rules affect triage
Rules apply only to the analyzer where you create them. If you run several analyzers, create the rule on each one.
Keeping rules healthy
- Name rules after the intent, such as
partner-bucket-partner-account-only, so a reviewer can tell why it exists. - Review the archived list on a schedule. Run
list-findings-v2with a filter onstatusequal toARCHIVEDand check that each item is still expected. - Delete rules you no longer need with
aws accessanalyzer delete-archive-rule. Archived findings that no longer match any rule stay archived until you change their status, so reactivate them if you want them reviewed again.
Exercise
A rule archives findings where resource equals arn:aws:s3:::example-partner-share. Someone later adds a statement with "Principal": "*" to that bucket's policy. Is the new public access reported as an active finding? How would you change the rule?
Show answer
No. The new public finding also has that resource, so the rule archives it and nobody is alerted. Add a principal.AWS criterion with the partner account ID, so only access granted to that account matches. The public finding then no longer matches and appears as active.