> ## Content Index
> Fetch the complete content index at: https://agarhouse.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# What to Check Before You Remove an AWS IAM Permission
- URL: https://agarhouse.com/check-before-removing-aws-iam-permissions/
- Published: 2026-11-27T13:00:00.000Z
- Updated: 2026-11-27T13:00:00.000Z
- Description: An IAM permission missing from an access report may still matter. Review three fictional S3 permissions and decide what to keep, narrow, or remove.
- Author: Meatball
- Tags: Cybersecurity, Tutorial, #agarhouse-slot-2026-11-27-0800

A report that says “I didn’t see this permission used” is not the same as a report that says “you can take it away.” If the permission runs a year-end job, a quiet month tells you very little. If the tool doesn’t cover that kind of event, even a busy month can look quiet.

In this exercise you’ll review one fictional AWS IAM role and decide what to narrow, what to keep, and what to remove. Then you’ll check the before-and-after policy against four sample requests. Everything runs on your computer with fake data. You don’t need an AWS account, the AWS CLI, or any credentials.

## 1\. Read the evidence before editing the policy

Imagine a role that reads files for a daily report, reads one object for a year-end audit, and used to delete temporary files. The example has a 30-day review window. AWS IAM Access Analyzer can generate a policy template from a selected period of up to 90 days, but it does not identify action-level activity for S3 data events in the generated policy. CloudTrail can log object calls such as `GetObject` and `DeleteObject` as data events; trails and event data stores don’t collect them by default. Even a separate CloudTrail search is only as useful as its logging coverage and filters.

- **Daily report: narrow the read.** In the fictional review, a separate CloudTrail data-event record shows the report’s role session successfully reading `daily/manifest.csv`. The job’s configuration and owner confirm it needs objects under `daily/`, not the entire bucket. Narrow the broad `s3:GetObject` allowance to that prefix.
- **Year-end audit: keep the documented read.** An audit runbook and its owner identify `audit/year-end.csv`. The annual job did not run during the sample. Retain its existing exact-object allowance until the audit can be exercised in an approved test. A quiet month is not evidence that an annual job is obsolete.
- **Retired cleanup: remove the delete allowance.** The fictional retirement ticket says the cleanup job was decommissioned, the current scheduler configuration has no replacement using this role, and the workload owner confirms no remaining delete dependency. That corroboration, not a missing `DeleteObject` entry, is the reason to remove the old statement.

The fictional role owner verified that the daily prefix and the named audit object are the only required read scopes. If that inventory were incomplete, leave unreviewed read access alone while you verify which workflows depend on it.

## 2\. Run the local before-and-after check

Use Python 3 in a terminal. Open a practice folder, run `python3 --version`, and save this entire block as `review_lab.py`. It uses only Python’s standard library.

```python
import json

BUCKET = "arn:aws:s3:::example-review-fixture"
DAILY = f"{BUCKET}/daily/manifest.csv"
AUDIT = f"{BUCKET}/audit/year-end.csv"
OLD = f"{BUCKET}/scratch/old.tmp"

# Each known scope expands only to these fixed fictional sample objects.
# This is a lookup table, not AWS ARN matching.
SAMPLES = {
    f"{BUCKET}/*": {DAILY, AUDIT, OLD},
    f"{BUCKET}/daily/*": {DAILY},
    AUDIT: {AUDIT},
    f"{BUCKET}/scratch/*": {OLD},
}

def allow(action, resource):
    return {"Effect": "Allow", "Action": action, "Resource": resource}

audit = allow("s3:GetObject", AUDIT)
before = {
    "Version": "2012-10-17",
    "Statement": [
        allow("s3:GetObject", f"{BUCKET}/*"),
        audit,
        allow("s3:DeleteObject", f"{BUCKET}/scratch/*"),
    ],
}
candidate = {
    "Version": "2012-10-17",
    "Statement": [
        allow("s3:GetObject", f"{BUCKET}/daily/*"),
        audit,
    ],
}

def fixture_pairs(policy):
    pairs = set()
    for statement in policy["Statement"]:
        if (set(statement) != {"Effect", "Action", "Resource"}
                or statement["Effect"] != "Allow"
                or statement["Action"] not in {"s3:GetObject", "s3:DeleteObject"}
                or statement["Resource"] not in SAMPLES):
            raise ValueError("Expected only the lab's fixed allow statements")
        for obj in SAMPLES[statement["Resource"]]:
            pairs.add((statement["Action"], obj))
    return pairs

# Expected membership of each exact (action, sample object) pair.
cases = [
    ("Daily read", "s3:GetObject", DAILY, True, True),
    ("Annual audit read", "s3:GetObject", AUDIT, True, True),
    ("Read outside required paths", "s3:GetObject", OLD, True, False),
    ("Retired cleanup delete", "s3:DeleteObject", OLD, True, False),
]
old_pairs, new_pairs = fixture_pairs(before), fixture_pairs(candidate)
for label, action, obj, was_expected, now_expected in cases:
    actual = ((action, obj) in old_pairs, (action, obj) in new_pairs)
    if actual != (was_expected, now_expected):
        raise RuntimeError(f"{label}: unexpected fixture results {actual}")
    print(f"{label}: {actual[0]} -> {actual[1]}")

print("All four fixture checks passed.")
print("\nCandidate policy (fictional; do not deploy):")
print(json.dumps(candidate, indent=2))
```

From that folder, run:

```bash
python3 review_lab.py
```

On Python 3.12.14 the four checks produced this summary, followed by the candidate JSON:

```
Daily read: True -> True
Annual audit read: True -> True
Read outside required paths: True -> False
Retired cleanup delete: True -> False
All four fixture checks passed.
```

Here `True` means that the exact action and sample object pair is present in this toy policy’s projected set. `False` means it is absent from that set, not that AWS would deny the request. The script deliberately maps only four known resource strings to three sample objects instead of interpreting AWS wildcards. It checks this exercise, not IAM generally. It has no support for conditions, explicit denies, other policy types, or any real authorization context.

The third check matters even though it is not a workload: it shows that a read of `scratch/old.tmp` no longer appears in this single candidate. To see the check catch a mistake, temporarily change the candidate’s `/daily/*` resource to the broader `/*` already defined in the script. Run it again: the out-of-scope read should raise `RuntimeError`. Restore the original candidate and rerun all four checks. If the untouched script fails, check that you copied the full block, including the sample map. When done, keep or delete only your practice script. There is no bucket or role to undo.

## 3\. Decide what would count as proof in AWS

In a real review, write down the dates and logging coverage you checked, the role and resource involved, the workload owner, and the evidence behind each decision. Test both requests that should still work and requests that should not. AWS’s IAM policy simulator can help, but it does not make live service requests, and results can differ from real authorization. Another identity policy or a bucket policy may still grant access after you remove this allowance. Validate with the intended role and representative nonproduction resources before considering a rollout. Don’t try a destructive check on a real object.

For a customer managed policy, record the known-good version and check every attachment before changing the default. The default applies to every user, group, or role attached to the policy. A retained previous version gives you a rollback option, but switching back also affects every attachment. Inline policies don’t have managed-policy version history. Recheck the jobs you kept after an approved rollout and watch for unexpected denials. When you cannot yet exercise a documented workflow, keep that dependency visible rather than declaring it unused.

## Sources

- [AWS IAM: what Access Analyzer policy generation can and cannot observe](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-generation.html?ref=agarhouse.com)
- [AWS CloudTrail: S3 object-level data events and logging coverage](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html?ref=agarhouse.com)
- [AWS IAM: policy simulator scope and differences from live requests](https://docs.aws.amazon.com/IAM/latest/UserGuide/access%5Fpolicies%5Ftesting-policies.html?ref=agarhouse.com)
- [AWS IAM: managed policy versions, default attachments, and rollback](https://docs.aws.amazon.com/IAM/latest/UserGuide/access%5Fpolicies%5Fmanaged-versioning.html?ref=agarhouse.com)