When to use this
You have been asked to "sort out the Inspector findings". The console shows thousands of them, some instances show as unscanned, and the patch team wants a list they can act on. This cheat sheet uses the aws inspector2 commands. Run them from the delegated administrator account to see the whole organization. The old Inspector Classic (aws inspector) is a different API.
1. Is Inspector on, and for what?
# Which scan types are enabled in this account and Region
aws inspector2 batch-get-account-status \
--query "accounts[].{account:accountId, state:state.status, ec2:resourceState.ec2.status, ecr:resourceState.ecr.status, lambda:resourceState.lambda.status}" \
--output table
# Enable scan types (delegated admin can pass --account-ids)
aws inspector2 enable --resource-types EC2 ECR LAMBDA
# Current EC2 scan mode and ECR re-scan settings
aws inspector2 get-configuration
Inspector is a regional service. Repeat these commands in every Region you run workloads in, or loop over aws ec2 describe-regions --query "Regions[].RegionName" --output text.
2. Find coverage gaps
A resource with no findings is not necessarily clean. It may just not be scanned. Start with the counts:
aws inspector2 list-coverage-statistics --group-by SCAN_STATUS_REASON \
--query "countsByGroup[].[groupKey,count]" --output table
aws inspector2 list-coverage-statistics --group-by RESOURCE_TYPE --output table
Then list the unscanned resources:
aws inspector2 list-coverage \
--filter-criteria '{"scanStatusCode":[{"comparison":"EQUALS","value":"INACTIVE"}]}' \
--query "coveredResources[].[resourceType,resourceId,scanStatus.reason]" --output table
| Scan status reason (common ones) | Cause | Fix |
|---|---|---|
UNMANAGED_EC2_INSTANCE | SSM Agent not running or no instance profile with SSM permissions (agent-based mode) | Fix SSM registration, or switch to hybrid scan mode |
NO_INVENTORY / STALE_INVENTORY | SSM inventory not collected or out of date | Check SSM Agent health and the Inspector SSM association |
UNSUPPORTED_OS | OS or version not supported for scanning | Check the supported OS list; upgrade or accept the gap |
EC2_INSTANCE_STOPPED | Instance is stopped | Expected; it is scanned again after it starts |
EXCLUDED_BY_TAG | Instance has the InspectorEc2Exclusion tag | Remove the tag if the exclusion was a mistake |
SCAN_ELIGIBILITY_EXPIRED | ECR image outside the re-scan duration | Extend rescanDuration or push a fresh image |
ACCESS_DENIED | Inspector cannot read the resource | Check the service-linked role and any SCP/resource policy denies |
Reason names change as new scan types appear, so check the values your own --group-by SCAN_STATUS_REASON output returns.
Agentless and hybrid EC2 scanning
Hybrid mode scans instances without SSM by taking EBS snapshots of them:
aws inspector2 update-configuration --ec2-configuration scanMode=EC2_HYBRID
Warning
Agentless scanning creates temporary EBS snapshots. SCPs or tag policies that block
ec2:CreateSnapshot, or KMS key policies that do not allow the Inspector service-linked role, cause silent coverage gaps on encrypted volumes. Test the change on one account before you roll it out to the organization.
ECR re-scan window
aws inspector2 update-configuration \
--ecr-configuration rescanDuration=DAYS_180
The allowed values vary by CLI version. Run aws inspector2 update-configuration help to see the ones your build accepts.
3. Pull the findings that matter
Severity alone gives you too many findings to work through. Start with findings that are critical or high, have a known exploit and have a fix available:
aws inspector2 list-findings \
--filter-criteria '{
"findingStatus":[{"comparison":"EQUALS","value":"ACTIVE"}],
"severity":[{"comparison":"EQUALS","value":"CRITICAL"},{"comparison":"EQUALS","value":"HIGH"}],
"exploitAvailable":[{"comparison":"EQUALS","value":"YES"}],
"fixAvailable":[{"comparison":"EQUALS","value":"YES"}]
}' \
--sort-criteria field=INSPECTOR_SCORE,sortOrder=DESC \
--query "findings[].[severity,inspectorScore,title,resources[0].id]" \
--output table --max-items 50
The filter fields used most often:
| Field | Example value | Use |
|---|---|---|
vulnerabilityId | CVE-2024-6387 | "Are we affected by this CVE?" |
resourceType | AWS_EC2_INSTANCE, AWS_ECR_CONTAINER_IMAGE, AWS_LAMBDA_FUNCTION | Split work by owning team |
ecrImageRepositoryName | payments-api | One repository's images |
ec2InstanceImageId | ami-0abc... | Everything inherited from one AMI |
awsAccountId | 111122223333 | One account in the org |
findingType | PACKAGE_VULNERABILITY, NETWORK_REACHABILITY | Patching vs exposure work |
String filters take EQUALS, NOT_EQUALS or PREFIX. The filters inside one field are ORed together, and separate fields are ANDed.
One CVE across the estate
aws inspector2 list-findings \
--filter-criteria '{"vulnerabilityId":[{"comparison":"EQUALS","value":"CVE-2024-6387"}],
"findingStatus":[{"comparison":"EQUALS","value":"ACTIVE"}]}' \
--query "findings[].[awsAccountId,resources[0].type,resources[0].id]" --output text
Group instead of listing
Aggregations tell you which patch fixes the most findings, or which AMI is the source of most of them:
aws inspector2 list-finding-aggregations --aggregation-type PACKAGE
aws inspector2 list-finding-aggregations --aggregation-type AMI
aws inspector2 list-finding-aggregations --aggregation-type ACCOUNT
If most findings trace back to one AMI, rebuild the golden AMI and refresh the fleet instead of patching each instance by hand.
4. Suppress noise with filters, not by ignoring it
Suppression rules hide matching findings now and in the future. Scope every rule as narrowly as you can and give a reason:
aws inspector2 create-filter \
--name "suppress-sandbox-low" \
--action SUPPRESS \
--reason "Sandbox accounts: low severity not tracked, reviewed quarterly" \
--filter-criteria '{
"awsAccountId":[{"comparison":"EQUALS","value":"444455556666"}],
"severity":[{"comparison":"EQUALS","value":"LOW"}]
}'
aws inspector2 list-filters --query "filters[].[name,action,reason]" --output table
aws inspector2 delete-filter --arn <filter-arn>
Caution
A broad suppression rule (for example "all findings in production with severity MEDIUM") also hides new CVEs that match it, including ones with a public exploit. Do not filter on severity alone in production accounts. Review suppression rules every quarter.
Findings for fixed or deleted resources move to CLOSED on their own. Do not suppress findings just to clear them.
5. Export a report for patch owners
aws inspector2 create-findings-report \
--report-format CSV \
--s3-destination bucketName=sec-reports-111122223333,keyPrefix=inspector/,kmsKeyArn=arn:aws:kms:eu-west-1:111122223333:key/<key-id> \
--filter-criteria '{"findingStatus":[{"comparison":"EQUALS","value":"ACTIVE"}],
"severity":[{"comparison":"EQUALS","value":"CRITICAL"}]}'
aws inspector2 get-findings-report-status --report-id <report-id>
The bucket policy must allow inspector2.amazonaws.com to write objects, and the KMS key policy must allow Inspector to use the key. If either is missing, the report status shows FAILED. You can also export an SBOM for an image or instance with create-sbom-export.
6. Route new criticals to on-call
Inspector publishes findings to EventBridge. This rule pattern matches new critical findings:
{
"source": ["aws.inspector2"],
"detail-type": ["Inspector2 Finding"],
"detail": { "severity": ["CRITICAL"], "status": ["ACTIVE"] }
}
aws events put-rule --name inspector-critical --event-pattern file://pattern.json
aws events put-targets --rule inspector-critical --targets Id=sns,Arn=arn:aws:sns:eu-west-1:111122223333:sec-oncall
The SNS topic policy must allow events.amazonaws.com to publish to it.
Prevent it next time
- Enable Inspector from the delegated administrator with auto-enable for new member accounts, so new accounts are not left uncovered.
- Alarm on coverage, not only on findings. Run a weekly check of the
INACTIVEcount per account. - Fix vulnerabilities at the source: patch AMIs and base images, then roll the fleet with instance refresh or redeploy containers.
- Keep suppression rules in IaC and tie each one to a ticket or an expiry date.
- Use Security Hub if you need Inspector findings next to GuardDuty and Config in one view.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get