Detect Threats with GuardDuty
Learn AWS GuardDuty basics: how it detects threats, the core concepts, and a hands-on walkthrough to start securing your cloud.
Focus: detect threats with guardduty basics
Imagine the worst Friday night in your career: your AWS account is under attack, and you only find out when your bill doubles. You can't watch every CloudTrail log, every VPC flow, and every DNS query by hand—there's simply too much data. That's where AWS GuardDuty comes in: it's the security guard that never sleeps, continuously monitoring your AWS environment for suspicious activity and alerting you before a small anomaly turns into a full-blown breach. In this lesson, you'll learn the basics of GuardDuty and how to use it to detect threats in your cloud account.
The problem this lesson solves
Manual threat detection is impossible at cloud scale. Your environment generates millions of events—API calls, network connections, and data access patterns—every day. Sifting through that noise to find real threats is like searching for a needle in a haystack armed only with a flashlight. Meanwhile, attackers are automating their scans and exploits, chipping away at misconfigurations or leaked credentials. Without an automated detection layer, you'll miss the early warning signs of intrusion, lateral movement, or data exfiltration. AWS GuardDuty exists to give you a 'radar' that sweeps your entire account continuously, separating the benign from the malicious so you can respond fast.
Core concept / mental model
Think of GuardDuty as a security camera system for your AWS environment. It's not a firewall that blocks traffic and not a compliance scanner that checks for weak passwords. It's a threat detection service that analyzes streams of data from three main sources:
- AWS CloudTrail events (API activity)
- VPC Flow Logs (network traffic)
- DNS logs (domain resolution)
GuardDuty feeds these into its threat intelligence and machine learning engines. It compares your activity against known malicious IPs, domains, and behavioral baselines that it builds per account. When something deviates—say, an EC2 instance starts communicating with a known command-and-control server—GuardDuty raises a finding. A finding is a concrete, prioritized alert with context: what happened, which resource is affected, how severe it is, and what to do next.
This is not a 'set and forget' service—you still own the response. GuardDuty detects; you decide how to remediate. Whether that's automated (via EventBridge) or manual (via the console), the mental model is detect > prioritize > respond.
How it works step by step
The step-by-step flow of GuardDuty detecting threats is:
- Enable GuardDuty in your AWS account (per region).
- GuardDuty automatically starts ingesting: - CloudTrail management events (e.g., console logins, IAM changes) - VPC Flow Logs (network connections) - DNS query logs - (Optional) Amazon EKS audit logs, RDS login events, and S3 data events if you enable those:
- The service applies threat intelligence (known bad IPs, domains) and machine learning (anomaly detection based on your activity patterns) to this stream.
- When a match or anomaly is detected, GuardDuty creates a finding with severity: Low, Medium, or High.
- Findings are aggregated on the GuardDuty console and optionally sent to Amazon EventBridge (formerly CloudWatch Events) to trigger automations, such as an SNS notification or a Lambda function that responds automatically.
- You review the finding details, assess impact, and take remediation steps (e.g., isolate an instance, rotate keys).
This takes minutes from detection to notification—not hours that manual log review would need.
Hands-on walkthrough
Let's get our hands dirty. You'll enable GuardDuty, generate a test finding, and verify the alert pipeline.
Prerequisites
- AWS account with sufficient permissions (you'll need
guardduty:CreateDetector,iam:PassRole, etc.) - AWS CLI installed and configured
- Optionally, the
aws-guardduty-testertool or access to EC2 for simulating malicious activity
Step 1: Enable GuardDuty via CLI
# Create a detector (this enables GuardDuty in the current region)
aws guardduty create-detector --enable
# Output will include a detector ID - copy it for later use.
Pro Tip: Use
--finding-publishing-frequency FIFTEEN_MINUTESto get alerts faster during testing, but defaultSIX_HOURSis fine for production to reduce noise.
Step 2: List detectors to confirm it's enabled
aws guardduty list-detectors
# Output:
# {
# "DetectorIds": ["a1b2c3d4e5f6..."]
# }
Step 3: Generate a test finding
You can manually create a test finding in the GuardDuty console (look for the 'Generate sample findings' button in the Settings tab). This creates sample findings like UnauthorizedAccess:EC2/SSHBruteForce. Alternatively, if you want a real-ish finding, you can use the open-source aws-guardduty-tester tool, which launches an EC2 instance and simulates traffic to a known bad IP. But for learning purposes, sample findings are perfect.
Step 4: Verify the finding
Once the sample finding is generated, check it:
# Replace <region> with your region and <detector-id> with your detector ID
aws guardduty list-findings --detector-id <detector-id>
# Then get details for a specific finding ID
aws guardduty get-findings --detector-id <detector-id> --finding-ids <finding-id>
You'll see JSON with fields like Type (e.g., UnauthorizedAccess:EC2/SSHBruteForce), Severity, Resource (the affected EC2), and Description. This is your detection signal.
Step 5: Set up an alert notification (optional)
To get notified in real-time, create an SNS topic and subscribe your email, then configure EventBridge to send GuardDuty findings to that topic:
# Create an SNS topic and subscribe (adjust email)
aws sns create-topic --name GuardDutyAlerts
aws sns subscribe --topic-arn arn:aws:sns:us-east-1:123456789012:GuardDutyAlerts --protocol email --notification-endpoint you@example.com
# Confirm the email subscription, then create an EventBridge rule
# (You can do this via console or CLI - see AWS docs for the exact commands)
Now you'll get an email the moment GuardDuty detects something.
Compare options / when to choose what
GuardDuty isn't your only detection tool. Here's how it stacks up against alternatives:
| Tool | Focus | Best for | Cost | Effort |
|---|---|---|---|---|
| GuardDuty | Threat detection via ML + threat intel | Continuous, automated monitoring across account | Moderate | Low |
| AWS Security Hub | Aggregates findings from multiple services | Central dashboard for compliance & security | Depends on sources | Low |
| Custom Lambda + CloudWatch | Ad-hoc rules and logic | Simple, specific custom alerts | Low | High |
| Third-party SIEM (e.g., Splunk) | Log ingestion and correlation | Large enterprises with existing SIEM | High | High |
When to choose GuardDuty: If you need a managed, baseline detection layer with minimal setup, GuardDuty is the default. It's often enabled first before anything else. When to pair with Security Hub: Security Hub gives you a single pane of glass across GuardDuty, Inspector, and other services. When to go custom: If you have niche detection needs (e.g., specific IAM patterns), you might add Lambda rules, but you should still use GuardDuty as the foundation. When to use a SIEM: Only when you have compliance requirements that demand centralized log management and correlation beyond AWS-native services.
Troubleshooting & edge cases
| Issue | Likely Cause | Solution |
|---|---|---|
| GuardDuty shows 'Not enabled' after creation | The enable call failed or you created it in a different region | Check you're in the correct region; use list-detectors to verify |
| No findings appear | Finding generation is disabled, or you haven't waited long enough | Wait up to 15 minutes with FIFTEEN_MINUTES frequency; generate sample findings to test |
| Test finding not showing | Sample findings only work if the detector is active for 30 minutes | Wait and retry, or use a third-party tool to simulate a real finding |
| EventBridge rule not triggering | IAM role missing for EventBridge to invoke SNS | Grant EventBridge permission to publish to SNS |
| High false positives | Baseline is learning from your normal traffic | Tune findings: suppress low-severity types, whitelist known-good IPs via trusted IP lists |
Edge cases to watch: - Multiple regions: GuardDuty is regional. Enable it in each region you use, or use AWS Organizations to enable across accounts. - Data sources: VPC Flow Logs are enabled by default but can be disabled; you may see fewer network findings if disabled.
What you learned & what's next
You've learned that GuardDuty is a continuous threat detection service that uses machine learning and threat intelligence to analyze CloudTrail, VPC Flow, and DNS logs—turning raw events into prioritized findings. You've enabled it, generated sample findings, and verified the alert pipeline, proving you can detect threats with GuardDuty basics. This is the foundation for the next lesson, where you'll learn how to create automated responses to GuardDuty findings using EventBridge and Lambda, turning detection into prevention. Keep your radar on—your cloud depends on it.
Practice recap
In this lesson, you enabled GuardDuty and generated sample findings. As a next step, try creating an EventBridge rule that sends findings to an SNS topic, and verify you receive an email alert. Also, explore the GuardDuty console to view the different finding types and their details—you'll be analyzing these in the next lesson on automated response.
Common mistakes
- Forgetting to enable GuardDuty in every region—threats can happen in any region, and GuardDuty is regional.
- Ignoring low-severity findings—attackers often start with low-severity probes before escalating.
- Setting EventBridge rules without proper IAM permissions—your alerts never fire silently.
- Disabling VPC Flow Logs for cost savings and then missing network-based detections.
Variations
- Use GuardDuty with AWS Organizations to enable across all accounts in one click, with centralized admin.
- Integrate GuardDuty with Security Hub to view findings alongside other security services like Inspector.
- Alternatively, use AWS Detective to investigate GuardDuty findings in depth with graph-based analysis.
Real-world use cases
- Detecting SSH brute-force attempts against EC2 instances and isolating the compromised instance automatically.
- Identifying a compromised IAM user by spotting unusual API calls from an unfamiliar IP and rotating credentials.
- Catching crypto-mining malware by detecting traffic to known mining pools and terminating the instance.
Key takeaways
- GuardDuty is a managed threat detection service—you don't inspect logs manually; it does the heavy lifting of finding threats.
- GuardDuty analyzes CloudTrail, VPC Flow Logs, and DNS logs continuously, using ML and threat intelligence to create findings.
- Findings are prioritized by severity and include actionable context, making response faster.
- Enable GuardDuty in every region and integrate with EventBridge for real-time alerting.
- Test your detection pipeline with sample findings to ensure it works before a real incident.
- GuardDuty is just the detection layer—you must also implement response automation and remediation.
Keep learning
Related tutorials, quizzes, and articles for this topic.
Discussion
Questions, corrections, and tips help everyone reading this page.
0 comments
Add a comment
No comments yet — start the thread.