
Shift Left with EC2 AMI Vulnerability Scanning in Amazon Inspector
Amazon Inspector now scans EC2 Amazon Machine Images (AMIs) for vulnerabilities without requiring you to launch instances or install agents. This capability moves security scanning earlier in your deployment pipeline, helping you fix issues at the source before they propagate across your fleet.
What's New
Amazon Inspector's AMI scanning introduces three key capabilities:
1. Agentless Vulnerability Detection
Scan AMIs directly for software vulnerabilities without launching instances or installing Inspector agents. This removes the operational overhead of maintaining scanning infrastructure and reduces the time between AMI creation and vulnerability discovery.
2. Continuous and On-Demand Scanning
- Continuous monitoring: Automatically evaluate your AMI catalog as new vulnerabilities are published (CVE database updates)
- One-time scans: Run targeted scans for specific AMIs directly from the EC2 Console
3. Organization-Wide Enforcement
Enable AMI scanning across your entire AWS Organization and integrate with Security Hub to centralize findings. Combine scanning with the Allowed AMIs feature and Declarative Policies to enforce security standards organization-wide.
Why This Matters
The Traditional AMI Security Gap
Before this feature, scanning AMIs for vulnerabilities required one of these approaches:
- Launch-and-scan: Spin up instances from the AMI, install Inspector agents, scan, then terminate — slow, costly, and requires networking/IAM configuration
- Build-time testing: Scan during the build pipeline before AMI creation — catches build-time vulnerabilities but misses newly discovered CVEs affecting older AMIs
- Instance-only scanning: Only scan running instances — vulnerabilities are discovered after deployment when remediation is more expensive
Each approach leaves a gap: AMIs sitting in your catalog could harbor newly discovered vulnerabilities that won't be detected until someone launches an instance from them.
The Shift-Left Advantage
AMI scanning closes this gap by treating AMIs as scannable artifacts. Now you can:
- Detect zero-day CVEs in your AMI library as soon as they're published, even for AMIs created months ago
- Block vulnerable AMIs from launching instances using Allowed AMIs policies
- Reduce blast radius by fixing vulnerabilities in the golden image instead of patching hundreds of running instances
- Accelerate compliance by proving your AMI catalog meets security standards before deployment
How It Works
Scanning Architecture
Amazon Inspector accesses AMI snapshots directly (the EBS snapshots backing your AMIs) and analyzes the filesystem contents without launching compute resources. The service:
- Reads package manifests (dpkg, rpm, APK databases)
- Identifies installed software versions
- Cross-references against CVE databases (NVD, vendor advisories)
- Generates findings with CVSS scores and remediation guidance
No network access, no agent installation, no instance launch — just snapshot-level analysis.
Enabling AMI Scanning
Single Account
# Enable AMI scanning in your accountaws inspector2 update-configuration \ --resource-types AMI \ --ecr-configuration '{"enable": true}'Organization-Wide
- Navigate to Amazon Inspector console
- Choose Account management → Delegated administrator
- Enable AMI scanning for the organization
- (Optional) Enable Security Hub integration to route findings
Security Hub Add-On
If you're a Security Hub customer, enable AMI scanning as an add-on to automatically deliver findings to Security Hub's centralized dashboard.
Scanning Modes
Continuous Monitoring (Recommended)
Once enabled, Inspector continuously monitors your AMI catalog. When a new CVE is published that affects software in your AMIs, Inspector generates findings automatically — no manual rescans needed.
One-Time Scans
From the EC2 Console:
- Select an AMI
- Choose Actions → Scan with Inspector
- Review findings in the Inspector console
Use one-time scans for ad-hoc verification before distributing an AMI or after applying patches.
Integration Patterns
Pattern 1: EC2 Image Builder + Inspector + Allowed AMIs
Goal: Only distribute AMIs that pass vulnerability thresholds.
# Image Builder pipeline with Inspector integrationResources: ImagePipeline: Type: AWS::ImageBuilder::ImagePipeline Properties: Name: SecureGoldenAMI ImageRecipeArn: !Ref MyImageRecipe InfrastructureConfigurationArn: !Ref InfraConfig ImageScanningConfiguration: ImageScanningEnabled: true # Enable Inspector scanning DistributionConfiguration: !Ref DistributionConfig
DistributionConfig: Type: AWS::ImageBuilder::DistributionConfiguration Properties: Name: ConditionalDistribution Distributions: - Region: us-east-1 AmiDistributionConfiguration: # Only distribute if scan passes LaunchPermissionConfiguration: UserGroups: - !If [InspectorPassed, "all", !Ref "AWS::NoValue"]Workflow:
- Image Builder creates the AMI
- Inspector scans the AMI automatically
- If critical/high vulnerabilities are found, block distribution
- If scan passes, distribute the AMI to accounts/regions
Enforcement with Allowed AMIs:
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Deny", "Action": "ec2:RunInstances", "Resource": "arn:aws:ec2:*::image/*", "Condition": { "StringNotEquals": { "ec2:ImageAttribute/Inspector/ScanStatus": "PASSED" } } }]}Attach this SCP via Declarative Policies to enforce that only scanned, passing AMIs can launch instances across your organization.
Pattern 2: Continuous AMI Catalog Monitoring
Goal: Track the security posture of all AMIs over time as new CVEs emerge.
# Lambda function: weekly AMI security reportimport boto3from collections import defaultdict
inspector = boto3.client('inspector2')ses = boto3.client('ses')
def lambda_handler(event, context): # Fetch all AMI findings findings = inspector.list_findings( filterCriteria={ 'resourceType': [{'comparison': 'EQUALS', 'value': 'AWS_EC2_AMI'}] } ) # Group by severity by_severity = defaultdict(list) for finding in findings['findings']: severity = finding['severity'] ami_id = finding['resources'][0]['id'].split('/')[-1] cve = finding['packageVulnerabilityDetails']['vulnerabilityId'] by_severity[severity].append({ 'ami': ami_id, 'cve': cve, 'score': finding.get('cvssScore', 'N/A') }) # Generate report report = f""" AMI Vulnerability Report - {datetime.now().date()} CRITICAL: {len(by_severity['CRITICAL'])} findings HIGH: {len(by_severity['HIGH'])} findings MEDIUM: {len(by_severity['MEDIUM'])} findings Action Required: {format_action_items(by_severity['CRITICAL'])} """ # Email security team ses.send_email( Source='security@example.com', Destination={'ToAddresses': ['secops@example.com']}, Message={'Subject': {'Data': 'AMI Security Report'}, 'Body': {'Text': {'Data': report}}} )EventBridge Rule to trigger on new AMI findings:
{ "source": ["aws.inspector2"], "detail-type": ["Inspector2 Finding"], "detail": { "resourceType": ["AWS_EC2_AMI"], "severity": ["CRITICAL", "HIGH"] }}Route high/critical AMI findings to a Lambda that opens Jira tickets, posts to Slack, or triggers automated remediation.
Pattern 3: Pre-Production Gate
Goal: Scan AMIs in a sandbox account before promoting to production.
#!/bin/bash# promote-ami.sh - only promote AMIs that pass security scan
AMI_ID=$1SOURCE_ACCOUNT="111122223333"PROD_ACCOUNT="444455556666"
# Wait for scan to completeecho "Scanning AMI ${AMI_ID}..."aws inspector2 create-findings-report \ --filter-criteria resourceType=AWS_EC2_AMI,resourceId=${AMI_ID} \ --report-format JSON \ --s3-destination bucketName=scan-reports,keyPrefix=ami-scans/
# Check findingsCRITICAL_COUNT=$(aws inspector2 list-findings \ --filter-criteria "resourceType=[{comparison=EQUALS,value=AWS_EC2_AMI}],resourceId=[{comparison=EQUALS,value=${AMI_ID}}],severity=[{comparison=EQUALS,value=CRITICAL}]" \ --query 'length(findings)' --output text)
if [ "$CRITICAL_COUNT" -gt 0 ]; then echo "❌ FAILED: ${CRITICAL_COUNT} critical vulnerabilities found" exit 1fi
# Copy to production accountecho "✅ PASSED: Promoting to production"aws ec2 copy-image \ --source-image-id ${AMI_ID} \ --source-region us-east-1 \ --region us-east-1 \ --name "prod-$(date +%Y%m%d)-${AMI_ID}" \ --destination-account ${PROD_ACCOUNT}Integrate this script into your CI/CD pipeline (GitHub Actions, GitLab CI, Jenkins) as a required gate before AMI promotion.
Practical Example: Securing a Multi-Account SaaS Platform
Scenario: You run a SaaS platform with 50 AWS accounts (dev, staging, prod replicas across regions). You maintain 12 golden AMIs (web servers, app servers, databases) that teams use to launch instances.
Challenge: Last month, a critical OpenSSL CVE (CVE-2026-XXXXX) was published. It took your team 72 hours to:
- Identify which AMIs contained the vulnerable version (manual inventory)
- Determine which accounts/regions had instances from those AMIs (tagging inconsistencies made this hard)
- Rebuild the 8 affected AMIs
- Notify teams to refresh their instances
Solution with AMI Scanning:
Before (Day 0): Enable AMI scanning organization-wide
# In the management accountaws inspector2 enable --resource-types AMI --account-ids $(aws organizations list-accounts --query 'Accounts[*].Id' --output text)Day CVE is Published (Day 1, 9:00 AM):
- Inspector automatically scans all 12 AMIs across all accounts
- Within 15 minutes, findings appear showing 8 AMIs contain OpenSSL 3.0.7 (vulnerable)
- EventBridge rule triggers Lambda → Jira ticket auto-created with full AMI list
- Security Hub dashboard shows consolidated view across all 50 accounts
Day 1, 10:00 AM:
- Engineering team rebuilds the 8 affected AMIs with OpenSSL 3.0.13 (patched)
- New AMIs uploaded → Inspector scans them automatically → no findings
Day 1, 11:00 AM:
- Update Allowed AMIs policy to deny launches from the 8 vulnerable AMIs
aws ec2 modify-image-attribute \ --image-id ami-vulnerable123 \ --attribute allowedLaunchPermissions \ --operation remove- Policy enforced via SCP across organization → teams cannot launch vulnerable instances anymore
Day 1, 2:00 PM:
- Publish patched AMIs to all regions/accounts
- Teams refresh instances at their own pace (the blast radius is contained — new launches are safe)
Time to Mitigation: 5 hours vs 72 hours (93% reduction)
Manual Effort: 2 hours vs 16 hours (87% reduction)
Cost Considerations
Pricing Model:
- AMI scanning: $0.09 per AMI scan (initial scan when AMI is first evaluated)
- Continuous monitoring: Included (re-scans when new CVEs are published are free)
- No charges for findings storage or API calls
Cost Example:
- 100 AMIs in your catalog
- Initial scan: 100 × $0.09 = $9.00 (one-time)
- Monthly continuous monitoring: $0 (subsequent rescans for new CVEs are included)
Comparison: Launching 100 t3.micro instances for 1 hour each to agent-scan AMIs would cost ~$0.50 in EC2 charges + operational overhead. AMI scanning is more expensive per scan but includes continuous monitoring and zero operational work.
Optimization Tip: Use one-time scans for transient/test AMIs. Enable continuous monitoring only for AMIs used in production or distributed across accounts.
Best Practices
1. Enable Continuous Monitoring for Golden AMIs
Any AMI that serves as a base for multiple instances (golden images, Image Builder outputs, marketplace AMIs you share) should have continuous monitoring enabled. New CVEs are discovered daily — yesterday's clean AMI may have a critical finding today.
2. Integrate Scanning Into Image Builder Pipelines
Make Inspector scanning a required step in your AMI build process:
ImageScanningConfiguration: ImageScanningEnabled: true EcrConfiguration: ContainerTags: ["latest", "v1.2.3"]If a scan fails (critical findings above your threshold), fail the pipeline and prevent distribution.
3. Use Allowed AMIs + Declarative Policies for Enforcement
Detection without enforcement is reactive. Combine scanning with Allowed AMIs to proactively prevent vulnerable AMI launches:
- Define security criteria (e.g., "No critical vulnerabilities")
- Apply as SCP across the organization
- Attempts to launch non-compliant AMIs are blocked at the API level
4. Route Findings to Security Hub
If you use Security Hub for centralized security posture management, enable AMI scanning as a Security Hub add-on. This aggregates AMI findings alongside GuardDuty, Config, and other security service findings in a single pane of glass.
5. Automate Remediation with EventBridge
Create EventBridge rules that trigger on high/critical AMI findings:
- Notify: Post to Slack, create Jira tickets, email security team
- Quarantine: Remove launch permissions from the AMI
- Rebuild: Trigger Image Builder pipeline to create a patched version
6. Tag AMIs for Scanning Policies
Use tags to control scanning behavior:
aws ec2 create-tags --resources ami-12345678 --tags Key=ScanPolicy,Value=Continuousaws ec2 create-tags --resources ami-testami999 --tags Key=ScanPolicy,Value=OneTimeWrite Lambda functions that inspect tags and enable/disable continuous monitoring accordingly.
7. Review Findings by CVSS Score, Not Just Severity
Amazon Inspector assigns severity based on CVSS scores, but context matters. A "High" severity finding in a package that's not exposed (e.g., a CLI tool in an API server AMI) may be lower priority than a "Medium" finding in a public-facing web server. Review the
packageVulnerabilityDetails and exploitAvailable fields in findings to prioritize remediation.Monitoring and Reporting
Key Metrics to Track
- AMI Vulnerability Density: Findings per AMI (track over time to measure improvement)
- Time to Remediation: Hours between finding creation and patched AMI release
- Scan Coverage: Percentage of AMIs with continuous monitoring enabled
- Launch Denials: Count of instance launches blocked by Allowed AMIs policies (indicates policy effectiveness)
CloudWatch Dashboard
{ "widgets": [ { "type": "metric", "properties": { "metrics": [ ["AWS/Inspector", "FindingsCount", {"stat": "Sum", "label": "Total AMI Findings"}], [".", ".", {"stat": "Sum", "dimensions": {"Severity": "CRITICAL"}}], [".", ".", {"stat": "Sum", "dimensions": {"Severity": "HIGH"}}] ], "period": 86400, "region": "us-east-1", "title": "AMI Vulnerability Findings (Last 30 Days)" } } ]}Compliance Reporting
Generate monthly compliance reports showing AMI security posture:
def generate_compliance_report(): amis = ec2.describe_images(Owners=['self'])['Images'] scanned = [ami for ami in amis if has_inspector_scan(ami['ImageId'])] compliance_rate = (len(scanned) / len(amis)) * 100 return { 'total_amis': len(amis), 'scanned_amis': len(scanned), 'compliance_rate': f"{compliance_rate:.1f}%", 'unscanned_amis': [ami['ImageId'] for ami in amis if ami not in scanned] }Regional Availability
AMI scanning is available in all commercial AWS Regions where Amazon Inspector is available, including:
- US East (N. Virginia, Ohio)
- US West (Oregon, N. California)
- Europe (Ireland, Frankfurt, London, Paris, Stockholm, Milan)
- Asia Pacific (Tokyo, Seoul, Singapore, Sydney, Mumbai, Hong Kong, Jakarta)
- Canada (Central)
- South America (São Paulo)
- Middle East (Bahrain, UAE)
- Africa (Cape Town)
Note: AWS GovCloud and China regions follow separate availability timelines — check the Amazon Inspector product page for updates.
Resources
- EC2 User Guide - AMI Scanning : Step-by-step setup and usage
- Amazon Inspector User Guide : Architecture and finding types
- Amazon Inspector Pricing : Detailed cost breakdown
- Allowed AMIs Documentation : Policy enforcement setup
- Image Builder Integration : Pipeline configuration
Conclusion
AMI vulnerability scanning in Amazon Inspector shifts security left by treating AMIs as first-class scannable artifacts. This capability closes the gap between AMI creation and vulnerability discovery, enabling you to:
- Fix once, deploy everywhere: Remediate vulnerabilities in the golden image instead of patching hundreds of instances
- Detect faster: Continuous monitoring catches newly published CVEs in your AMI catalog within minutes
- Enforce proactively: Allowed AMIs policies prevent vulnerable AMIs from launching instances, reducing blast radius
By integrating AMI scanning into your Image Builder pipelines, enforcing compliance with Declarative Policies, and automating remediation with EventBridge, you can build a robust, shift-left security posture for your EC2 compute infrastructure.
Start with continuous monitoring for your production golden AMIs, measure time-to-remediation, and iterate on automation. The operational leverage — scanning hundreds of AMIs in seconds without launching a single instance — makes this one of the highest-ROI security capabilities AWS has shipped in 2026.
About the author
Ashish Kasaudhan is a DevSecOps Architect at Giesecke+Devrient (G+D) and a DevOps and platform engineer with 17 years of experience across cloud infrastructure, containerization, CI/CD and enterprise automation.
He is a member of the AWS Community Builders program and writes practitioner-focused posts on cloud, DevOps, AIOps and MLOps.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article