Fix three coverage report misclassifications - #209
Merged
Conversation
Skip SSM sessions in the tagging API supplement, treat IAM Identity Center reserved roles as untaggable, and collect Lambda layers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three resource types were being classified wrongly by the coverage report. All three were found by reconciling a full run against the open tickets on #203 — the resources turned up as "unmanaged with no ticket" when none of them can be managed at all.
1. SSM sessions were counted as unmanaged resources
The tagging API supplement has no type filter, so it added whatever
resourcegroupstaggingapi get-resourcesreturned. That includes SSM sessions: everyecs execute-commandleaves one in session history, and each landed in the report as an untagged — therefore unmanaged — resource.This is worse than it first looks. Sessions age out of history on their own, so it is not a slow leak; it means the denominator moves depending on whether anyone happened to shell into a container in the days before the run. Two runs on 2026-08-31 disagreed for exactly this reason, which matters because the coverage ratio is the metric #203 is tracked against.
Fixed with a skip list,
$script:TaggingApiSkipPatterns, so another such type can be added later without restructuring the collector.2. IAM Identity Center reserved roles were counted as unmanaged
AWSReservedSSO_AdministratorAccess_…sits under/aws-reserved/. Identity Center re-provisions these from permission sets and discards tags written to them, so they cannot holdmanaged-by— the same situation as the/aws-service-role/case the script already handled one branch above.3. Lambda layers were not collected at all
Add-LambdaResourcescalledlambda list-functionsonly, and the tagging API does not return layers, so they were invisible. This was found the hard way: the layersqlalchemy:2was part of the multi-tenant-db stack and had to be read out of the function's config, because nothing in the report knew it existed.The taggable unit is the layer, not the layer version.
lambda list-tagsacceptsarn:...:layer:<name>and rejectsarn:...:layer:<name>:<version>with aValidationException, so versions are counted through their layer — the same shape as ECS task definition revisions being counted through their family.Effect
Verified against
035866691871before and after. Unmanaged 90 → 81, of which 6 were the separately-deleted multi-tenant-db stack, so this change accounts for 3: two sessions dropped and the SSO role reclassified. Coverage 71.1% → 71.9%.Untaggable gains one row with a new reason,
IAM Identity Center reserved role. No resource moved into or out ofterraform-incubatororterraform-devops-security, which is the property that matters — this changes only what is counted, never what is reported as managed.Testing
035866691871across both regions, before and after, diffed by ARN.session/ecs-execute-commandrows, the SSO role present asuntaggablewith the new note, and the managed buckets unchanged at 191 / 16.Test-TaggingApiSkipchecked against sessions in both regions plus three ARNs that must not match, includingssm:...:parameter/rds_credentials.PSParser::Tokenize.The layer collector currently runs against an empty set — the account has zero Lambda layers now that
sqlalchemyis gone, so the loop is exercised but adds no rows. The ARN shape and the tagging behaviour were confirmed against the live API before it was deleted.Not included
Four resources also came out of that reconciliation as unmanageable-but-counted —
OrganizationAccountAccessRole, the IAM Access Analyzer service-role pair, and thedefault.postgres13/default.postgres15parameter groups. These are all genuinely taggable, so marking themuntaggablein the script would be a lie. They want a hand-appliedmanaged-by=exempttag instead, which is a change to AWS rather than to this script, and in the case ofOrganizationAccountAccessRolea decision first — it is a standing cross-account AdministratorAccess path, so "exempt" may be the wrong answer.Both blind-spot lists are updated, the one in
README.mdand the one the script prints after every run.