GuardDuty, Inspector, and Macie
Enable GuardDuty for threat detection, run Inspector for vulnerability scanning on EC2 and Lambda, and discover sensitive data in S3 with Macie.
GuardDuty, Inspector, and Macie is a free AWS Solutions Architect lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Threat Detection Layer
Defence-in-depth security requires not just preventing attacks but also detecting threats that slip through. AWS provides three managed security detection services that work together: Amazon GuardDuty detects threats by analysing AWS account behaviour and network traffic. Amazon Inspector finds software vulnerabilities in compute resources. Amazon Macie discovers sensitive data (PII, financial records) in S3 and alerts when it is exposed. All three are fully managed, use machine learning, and integrate with AWS Security Hub for centralised visibility.
# Detective controls overview:
# GuardDuty: Who is behaving suspiciously? (threat detection)
# Inspector: What vulnerabilities exist in my compute? (CVE scanning)
# Macie: Where is my sensitive data? (PII/PCI discovery)
# All three:
# - Fully managed (no agents for most features)
# - Machine learning-based analysis
# - Send findings to Security Hub
# - Integrate with EventBridge for automated responseAmazon GuardDuty: Intelligent Threat Detection
Amazon GuardDuty is a continuous threat detection service that analyses VPC Flow Logs, DNS logs, CloudTrail management events, and S3 data events using machine learning, anomaly detection, and integrated threat intelligence feeds (IP reputation lists, known malicious domains). GuardDuty is agentless — you enable it in your account and it immediately starts analysing existing logs. No infrastructure to manage, no log storage costs (GuardDuty consumes the logs directly from AWS). It surfaces findings categorised by threat type: UnauthorizedAccess, CryptoCurrency, Backdoor, Trojan, and more.
# Enable GuardDuty
aws guardduty create-detector \
--enable \
--finding-publishing-frequency FIFTEEN_MINUTES
# List GuardDuty findings
aws guardduty list-findings \
--detector-id <detector-id> \
--finding-criteria '{
"Criterion": {
"severity": {"Gte": 7}
}
}'
# High severity (7-10) examples:
# UnauthorizedAccess:EC2/MaliciousIPCaller.Custom
# CryptoCurrency:EC2/BitcoinTool.B
# Backdoor:EC2/C&CActivity.BGuardDuty Finding Types
GuardDuty classifies findings by threat purpose, resource type, and threat name. Common finding categories: UnauthorizedAccess — API calls from unusual locations or Tor exit nodes. Recon — port scanning or API enumeration. PrivilegeEscalation — IAM policy changes suggesting privilege escalation. Exfiltration — unusual large data retrieval from S3 or RDS. CryptoCurrency — EC2 instance communicating with known crypto mining pools. Stealth — CloudTrail logging disabled, S3 access logging disabled. Each finding includes an affected resource, actor IP/user, and recommended action.
# Get GuardDuty finding details
aws guardduty get-findings \
--detector-id <detector-id> \
--finding-ids finding-id-1 finding-id-2
# Finding structure:
# {
# 'type': 'CryptoCurrency:EC2/BitcoinTool.B!DNS',
# 'severity': 8.0,
# 'title': 'EC2 instance querying domain for cryptocurrency mining',
# 'resource': {'instanceDetails': {'instanceId': 'i-12345'}},
# 'service': {'action': {'networkConnectionAction': {'remoteIpDetails': {...}}}}
# }GuardDuty Automated Response
GuardDuty findings integrate with Amazon EventBridge to trigger automated response workflows. A common pattern: GuardDuty detects a compromised EC2 instance → EventBridge rule fires → Lambda function is invoked → Lambda isolates the instance (removes it from ASG, applies restrictive security group that blocks all traffic), snapshots its EBS volumes for forensics, and notifies the security team via SNS. This automated response can happen within seconds of detection — far faster than a human-operated response.
# EventBridge rule for high-severity GuardDuty findings
aws events put-rule \
--name guardduty-high-severity \
--event-pattern '{
"source": ["aws.guardduty"],
"detail-type": ["GuardDuty Finding"],
"detail": {
"severity": [{"numeric": [">", 6.9]}]
}
}'
# Lambda response function actions:
# 1. Stop instance from ASG
# 2. Replace security group with deny-all SG
# 3. Create EBS snapshot for forensics
# 4. Send SNS alert to security team
# 5. Create Jira ticket via APIAmazon Inspector: Vulnerability Assessment
Amazon Inspector automatically discovers and scans your workloads for software vulnerabilities and unintended network exposure. Inspector v2 (the modern version) covers EC2 instances (via Systems Manager Agent), Amazon ECR container images (scanned when pushed), and AWS Lambda functions (package dependencies). It correlates findings with CVE databases (Common Vulnerabilities and Exposures) and assigns risk scores. Inspector continuously rescans resources when new vulnerabilities are published — you do not need to manually trigger scans.
# Enable Amazon Inspector
aws inspector2 enable \
--resource-types EC2 ECR LAMBDA
# List Inspector findings for critical vulnerabilities
aws inspector2 list-findings \
--filter-criteria '{
"severity": [{"comparison":"EQUALS","value":"CRITICAL"}]
}' \
--query 'findings[].{Resource:resources[0].id,CVE:packageVulnerabilityDetails.vulnerabilityId,CVSS:packageVulnerabilityDetails.cvss[0].baseScore}'
# Inspector integrates with ECR lifecycle policies
# to prevent deploying critically vulnerable imagesInspector Network Reachability
Beyond CVE scanning, Inspector analyses network reachability — which EC2 instances are internet-accessible due to security group configurations. It maps your VPC security groups, NACLs, route tables, and internet gateways to determine which ports on which instances are reachable from the internet. A finding like Port 22 (SSH) on i-12345 is reachable from the internet indicates a misconfigured security group allowing direct SSH access — a common security risk. This network analysis runs without agents, using VPC configuration data.
# Inspector network findings example:
# Finding type: NETWORK_REACHABILITY
# Title: Port 22 is reachable from 0.0.0.0/0
# Resource: ec2-instance i-12345 (prod-web-01)
# Details: Security group sg-abc allows 0.0.0.0/0:22
# Recommendation: Restrict SSH to corporate IP range
# or use Systems Manager Session Manager instead
# Fix: update security group
aws ec2 revoke-security-group-ingress \
--group-id sg-abc \
--protocol tcp --port 22 --cidr 0.0.0.0/0Amazon Macie: Sensitive Data Discovery
Amazon Macie uses machine learning and pattern matching to automatically discover and protect sensitive data in Amazon S3. Macie identifies Personally Identifiable Information (PII) (names, social security numbers, credit card numbers, passports), financial data, health information, and credentials (passwords, API keys). It also detects public S3 buckets and unencrypted buckets. Macie generates findings that integrate with Security Hub and EventBridge for automated remediation or alerting when sensitive data is discovered or exposed.
# Enable Macie
aws macie2 enable-macie
# Create a classification job to scan S3 buckets
aws macie2 create-classification-job \
--name 'Scan-All-S3-Buckets' \
--job-type ONE_TIME \
--s3-job-definition '{
"bucketDefinitions": [{
"accountId": "123456789012",
"buckets": ["customer-uploads","financial-reports"]
}]
}' \
--managed-data-identifier-selector ALL
# Macie scans objects and reports:
# - SSN found in financial-reports/2026-q1.csv
# - Bucket customer-uploads is publicly readableMacie Findings and Compliance
Macie is particularly valuable for compliance frameworks that require locating and protecting sensitive data: GDPR (EU personal data), HIPAA (health information), PCI DSS (payment card data). Macie findings show which S3 objects contain sensitive data, what type of data was found, and the access controls on the bucket. Use this to verify that all buckets containing sensitive data are encrypted, private, and governed by appropriate bucket policies. Macie does not modify data or bucket access — it only detects and reports. Remediation is done by the security team.
# Get Macie findings
aws macie2 list-findings \
--finding-criteria '{
"criterion": {
"category": {"eqExactMatch": ["CLASSIFICATION"]}
}
}'
# Findings example output:
# sensitiveDataCategories: [FINANCIAL_INFORMATION, PERSONAL_HEALTH_INFORMATION]
# resourcesAffected:
# s3Object:
# bucketName: healthcare-records
# key: patients/2026/march.csv
# publicAccess: false (good)
# serverSideEncryption: null (BAD - not encrypted!)AWS Security Hub: Centralising Findings
AWS Security Hub aggregates findings from GuardDuty, Inspector, Macie, IAM Access Analyzer, Firewall Manager, and third-party tools into a single console. It normalises findings into the AWS Security Finding Format (ASFF), enabling consistent processing and analysis across sources. Security Hub also evaluates your environment against security standards like CIS AWS Foundations, PCI DSS, and NIST. Use Security Hub as the single pane of glass for your security posture — correlate related findings from multiple services to understand the full scope of an incident.
# Enable Security Hub and all integrations
aws securityhub enable-security-hub \
--enable-default-standards
# GuardDuty, Inspector, Macie automatically
# send findings to Security Hub when all are enabled
# Query aggregated findings
aws securityhub get-findings \
--filters '{
"SeverityLabel": [{"Value":"CRITICAL","Comparison":"EQUALS"}],
"WorkflowStatus": [{"Value":"NEW","Comparison":"EQUALS"}]
}' \
--sort-criteria '[{"Field":"LastObservedAt","SortOrder":"desc"}]'Comparing GuardDuty, Inspector, and Macie
The SAA-C03 exam tests whether you can select the right detective service for a given security requirement. Key distinctions: GuardDuty — detects runtime threats and suspicious behaviour (who is doing something bad NOW). Inspector — finds pre-existing vulnerabilities in software and network configuration (what is wrong with my resources). Macie — discovers sensitive data and its exposure risk in S3 (where is my sensitive data and is it protected). All three are complementary and are typically deployed together in production environments as part of a comprehensive security strategy.
# Service selection guide:
# 'Detect if EC2 is mining cryptocurrency' -> GuardDuty
# 'Find unpatched Apache Log4j vulnerabilities' -> Inspector
# 'Discover PII stored in S3 buckets' -> Macie
# 'Alert if unusual API calls from foreign IP' -> GuardDuty
# 'Find publicly accessible EC2 ports' -> Inspector
# 'Detect unencrypted S3 buckets with credit card data' -> Macie
# 'Correlate findings from all three services' -> Security HubEnabling at Scale with AWS Organizations
Manually enabling GuardDuty, Inspector, and Macie in each AWS account is impractical at scale. AWS Organizations integration lets you designate a delegated administrator account (typically a Security account) that enables and manages these services across all member accounts from a single place. New accounts added to the Organisation automatically have GuardDuty, Inspector, and Macie enabled. Findings from all accounts aggregate into the delegated administrator account for centralised review. This is the recommended architecture for multi-account security governance.
# Enable GuardDuty for entire AWS Organization
# Run from management account
aws guardduty enable-organization-admin-account \
--admin-account-id 111111111111
# From security/delegated admin account:
aws guardduty update-organization-configuration \
--detector-id <detector-id> \
--auto-enable-organization-members NEW
# NEW accounts automatically get GuardDuty enabled
# All findings aggregate in the admin accountQuick Check
Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.
Lesson Recap
In this lesson you learned: GuardDuty detects runtime threats through ML-based analysis of CloudTrail, VPC Flow Logs, and DNS logs, Inspector automatically scans EC2, ECR, and Lambda for CVE vulnerabilities and network reachability issues, and Macie discovers and protects sensitive data in S3 through managed data identifier scanning. Security Hub centralises findings from all three. Next up we explore Secrets Manager and Parameter Store.
Frequently asked questions
Is the “GuardDuty, Inspector, and Macie” lesson free?
Yes — the full text of “GuardDuty, Inspector, and Macie” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.
What will I learn in “GuardDuty, Inspector, and Macie”?
Enable GuardDuty for threat detection, run Inspector for vulnerability scanning on EC2 and Lambda, and discover sensitive data in S3 with Macie. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Solutions Architect?
No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “GuardDuty, Inspector, and Macie” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Solutions Architect lesson?
Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- KMS, ACM, and Encryption Patterns
- GuardDuty, Inspector, and Macie
- Secrets Manager and Parameter Store
- WAF, Shield, and Network Firewall