GuardDuty and Security Hub
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Operations and security
-
Phase 3: SQL Server on AWS
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Most teams find out about a compromised key when the bill arrives. AWS GuardDuty catches it sooner by watching CloudTrail, VPC flow data and DNS queries for signs of attack, like crypto-mining, stolen credentials being used from outside AWS, or someone probing your servers, and it raises findings with a severity attached.
You’ll switch GuardDuty on, generate some sample findings, send the high-severity ones to your saat-alerts email through EventBridge, and turn on Security Hub so everything lands in one place. Then you’ll fix the two reasons security alerts can quietly fail to arrive.
| Time | You need | By the end you can |
|---|---|---|
| 45 minutes | Lesson 23 done (saat-alerts with a confirmed email), your laptop signed in as saat-admin. Cost: GuardDuty and Security Hub both have a 30-day trial for new accounts in each Region, and you turn both off at the end. | Enable GuardDuty, read findings and their severities, route findings with an EventBridge rule and an SNS topic policy, test event patterns, and enable Security Hub CSPM with the default standards. |
What it is, in one line
AWS GuardDuty is a threat detection service that analyses your AWS logs and raises findings when it spots signs of compromise or attack in your account.
In Simple Words
The security guard watching the cameras
A building can have cameras everywhere, but nobody can watch fifty screens all night, so a good guard knows what to look out for: someone trying every door handle, a visitor walking out with a box at 3 a.m., or a staff badge used in two cities at once. GuardDuty is that guard for your AWS account, the cameras are logs AWS already keeps, and when something looks wrong the guard writes a note saying how serious it is. A note left on a desk doesn’t help anybody at night, though, so for the serious ones somebody has to get a phone call, and that call is the EventBridge rule and SNS email you’ll build.
Engineer's View
How GuardDuty and Security Hub really work
You turn GuardDuty on per Region with a detector. It reads CloudTrail management events, VPC flow logs and DNS logs from its own copies, so you don’t have to enable those yourself, and you can add optional protection plans for S3 data events, EKS, runtime monitoring, malware scanning of EBS volumes, RDS login activity and Lambda. It works from threat intelligence and machine learning, and Extended Threat Detection ties related events together into attack sequences.
Every finding has a type such as CryptoCurrency:EC2/BitcoinTool.B!DNS (threat purpose, resource, details), a severity from 1 to 10, and the resource it affects. Findings show up in the console and in Security Hub, and they also go to EventBridge, which is where you hook in alerts and automation. Suppression rules archive the findings you expect.
Security Hub CSPM is the original Security Hub, renamed in 2025. It runs compliance checks such as AWS Foundational Security Best Practices and pulls in findings from GuardDuty, Inspector, Macie and Config, and the newer Security Hub adds correlated risk analysis across those signals. Both are Regional, and both work best when you enable them across an organization from a delegated administrator account.
How it works, step by step
This is how one finding turns into an email.
1GuardDuty sees something
Say a server’s DNS queries start going to a known crypto-mining pool, or credentials issued to an EC2 instance get used from an IP outside AWS. GuardDuty raises a finding.
2EventBridge receives an event
Each finding is also an event, with source: aws.guardduty and detail-type: GuardDuty Finding, and a rule matches on fields like severity.
3SNS delivers it
The rule’s target is saat-alerts, and the topic’s access policy has to allow EventBridge to publish, otherwise delivery fails without telling anyone.
4Severity decides who acts
Not every finding is worth waking someone up for:
A common setup pages for 7 and above, sends medium ones to a team channel and reviews low ones weekly, with suppression rules for known, accepted activity like a scanner you run yourself.
✅ Checkpoint: You can explain what GuardDuty reads, how a finding ends up as an email, and why the SNS topic policy matters.
Hands-on lab: AWS GuardDuty findings that reach a person
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
Sign in and set up the names:
cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$acct = aws sts get-caller-identity --query Account --output text
$topic = "arn:aws:sns:ap-south-1:$($acct):saat-alerts"1Turn on GuardDuty
Paste this whole block:
$det = aws guardduty create-detector --enable --finding-publishing-frequency FIFTEEN_MINUTES --tags course=saatvedha-aws --query DetectorId --output text
aws guardduty get-detector --detector-id $det --query "[Status,FindingPublishingFrequency]" --output textYou should see this:
ENABLED FIFTEEN_MINUTESThat’s all GuardDuty needs. It starts reading your account’s logs straight away, with no agents to install and no logs to set up.
2Generate and read sample findings
Paste this whole block:
aws guardduty create-sample-findings --detector-id $det --finding-types "Recon:EC2/PortProbeUnprotectedPort" "UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS" "CryptoCurrency:EC2/BitcoinTool.B!DNS"
Start-Sleep 20
$ids = aws guardduty list-findings --detector-id $det --query FindingIds --output text
aws guardduty get-findings --detector-id $det --finding-ids ($ids -split '\s+') --query "sort_by(Findings, &Severity)[::-1].[Severity,Type]" --output textYou should see something like this:
8.0 CryptoCurrency:EC2/BitcoinTool.B!DNS
8.0 UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS
2.0 Recon:EC2/PortProbeUnprotectedPortSample findings have [SAMPLE] in their titles and point at made-up resources. In a real account the second one would mean credentials from an instance role are being used somewhere else, which is the most urgent kind of finding there is, so you’d rotate and investigate right away.
3Route high findings to saat-alerts
Paste the whole block and keep an eye on your inbox:
@'
{
"source": [ "aws.guardduty" ],
"detail-type": [ "GuardDuty Finding" ],
"detail": { "severity": [ { "numeric": [ ">=", 7 ] } ] }
}
'@ | Set-Content gd-pattern.json
$ruleArn = aws events put-rule --name saat-guardduty-high --event-pattern file://gd-pattern.json --state ENABLED --description "GuardDuty severity 7 and above to saat-alerts" --query RuleArn --output text
aws events put-targets --rule saat-guardduty-high --targets "Id=sns,Arn=$topic" | Out-Null
$pol = aws sns get-topic-attributes --topic-arn $topic --query Attributes.Policy --output text | ConvertFrom-Json
$pol.Statement += [pscustomobject]@{ Sid = 'AllowEventBridgeGuardDuty'; Effect = 'Allow'; Principal = @{ Service = 'events.amazonaws.com' }; Action = 'sns:Publish'; Resource = $topic; Condition = @{ ArnEquals = @{ 'aws:SourceArn' = $ruleArn } } }
$pol | ConvertTo-Json -Depth 10 | Set-Content topic-policy.json
aws sns set-topic-attributes --topic-arn $topic --attribute-name Policy --attribute-value file://topic-policy.json
aws guardduty create-sample-findings --detector-id $det --finding-types "CryptoCurrency:EC2/BitcoinTool.B!DNS"
"$((Get-Content topic-policy.json | ConvertFrom-Json).Statement.Sid -join ', ')"You should see something like this, and an email from AWS Notifications should turn up within about five minutes:
__default_statement_ID, AllowEventBridgeGuardDutyThe email body is the raw finding JSON. Teams usually put a small Lambda function or a chat integration in the middle to format it, but the routing works the same way.

4Turn on Security Hub
Paste this whole block:
aws securityhub enable-security-hub --enable-default-standards --tags course=saatvedha-aws
aws securityhub describe-hub --query "[HubArn,AutoEnableControls]" --output text
aws securityhub get-enabled-standards --query "length(StandardsSubscriptions)"You should see something like this:
arn:aws:securityhub:ap-south-1:111122223333:hub/default True
2Security Hub CSPM is now running the checks from the default standards against your account and importing GuardDuty findings. Scores take a few hours to show up, so if you leave it on for a day, open Security Hub in the console to see which controls are failing.

✅ Checkpoint: GuardDuty is ENABLED, three sample findings are listed with their severities, a high-severity finding got to your email through saat-guardduty-high, and Security Hub is on. Keep it all for the break lab.
Break It, Then Fix It
Security alerts get lost in two ways: either the rule never matches, or it matches and the delivery fails.
1Break it: one wrong letter in the event pattern
Test the real pattern, and a copy with a lowercase f, against a sample event:
[ordered]@{ version = '0'; id = 'test-1'; 'detail-type' = 'GuardDuty Finding'; source = 'aws.guardduty'; account = $acct; time = '2026-10-20T12:00:00Z'; region = 'ap-south-1'; resources = @(); detail = @{ severity = 8 } } | ConvertTo-Json -Depth 5 | Set-Content sample-event.json
(Get-Content gd-pattern.json -Raw) -replace 'GuardDuty Finding', 'GuardDuty finding' | Set-Content gd-pattern-typo.json
aws events test-event-pattern --event-pattern file://gd-pattern.json --event file://sample-event.json --output json
aws events test-event-pattern --event-pattern file://gd-pattern-typo.json --event file://sample-event.json --output jsonYou should see this:
{
"Result": true
}
{
"Result": false
}Event patterns are exact and case-sensitive, so a rule with the typo gets accepted, shows ENABLED and never fires. Fix: test every pattern with test-event-pattern against a real sample event before you rely on it, and for important rules, alarm on the rule’s MatchedEvents staying at zero.
2Break it: a topic that won’t accept EventBridge
Take the EventBridge statement out of the topic policy, create another high finding, and check the rule’s metrics after five minutes:
$pol = Get-Content topic-policy.json | ConvertFrom-Json
$pol.Statement = @($pol.Statement | Where-Object { $_.Sid -ne 'AllowEventBridgeGuardDuty' })
$pol | ConvertTo-Json -Depth 10 | Set-Content topic-policy-owner.json
aws sns set-topic-attributes --topic-arn $topic --attribute-name Policy --attribute-value file://topic-policy-owner.json
aws guardduty create-sample-findings --detector-id $det --finding-types "UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS"
Start-Sleep 300
aws cloudwatch get-metric-statistics --namespace AWS/Events --metric-name FailedInvocations --dimensions Name=RuleName,Value=saat-guardduty-high --start-time (Get-Date).ToUniversalTime().AddMinutes(-15).ToString('o') --end-time (Get-Date).ToUniversalTime().ToString('o') --period 900 --statistics Sum --query "Datapoints[0].Sum" --output textYou should see something like this, and no email will come:
1.0
The rule matched and EventBridge tried to deliver, but SNS refused because nothing in the topic policy allows events.amazonaws.com. You won’t see an error anywhere you’d normally look, and this metric is the only place it shows up. Fix: put the statement back, and add an alarm on FailedInvocations for your alert rules:
aws sns set-topic-attributes --topic-arn $topic --attribute-name Policy --attribute-value file://topic-policy.json
aws guardduty create-sample-findings --detector-id $det --finding-types "UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS"In about five minutes the email starts arriving again.
Now clean up. saat-alerts stays, with its original policy put back:
aws events remove-targets --rule saat-guardduty-high --ids sns | Out-Null
aws events delete-rule --name saat-guardduty-high
aws sns set-topic-attributes --topic-arn $topic --attribute-name Policy --attribute-value file://topic-policy-owner.json
aws guardduty delete-detector --detector-id $det
aws securityhub disable-security-hub
Remove-Item gd-pattern*.json, sample-event.json, topic-policy*.json
aws guardduty list-detectors --query "length(DetectorIds)"The last command should show:
0✅ Checkpoint: You caught a pattern that never matches using test-event-pattern, found a failed delivery through FailedInvocations, and fixed both. GuardDuty and Security Hub are off, and saat-alerts has its original policy again.
This happened at work
The alerts that went nowhere for three months
A gaming company turned on GuardDuty in all Regions and built an EventBridge rule that sent high findings to an SNS topic, which paged the security team. They tested it once with a sample finding, it worked, and everyone moved on to other things. Months later a platform team swapped that topic for a new one created by infrastructure code, and the new topic came with a default policy that didn’t have the EventBridge statement. When a real finding came in (an IAM user’s keys being used from an unusual country), it sat in the console for 11 days while the attacker read through customer support tickets. Now the team alarms on FailedInvocations for every security rule, sends a synthetic sample finding every week and checks it arrives, and keeps the rule, target and topic policy together in one stack so they can’t drift apart.
Common mistakes and troubleshooting
| Mistake | What happens | What to do |
|---|---|---|
| SNS topic policy without events.amazonaws.com | Rule matches, delivery fails silently | Allow sns:Publish for the rule ARN; alarm on FailedInvocations |
| Typos in event patterns | Rule never matches | Use test-event-pattern before deploying |
| GuardDuty in one Region only | Attacks in other Regions are unseen | Enable in every Region, ideally organization-wide |
| Paging on every finding | Alert fatigue; real ones ignored | Route by severity; suppress known activity |
| Ignoring credential exfiltration findings | Stolen keys stay usable | Treat as urgent: revoke sessions, rotate, investigate |
| Turning GuardDuty off after the trial to save cost | No detection when it matters | Check cost by plan; keep core detection on |
Interview questions
Click a question to open it. Each one is phrased the way an interviewer would ask it, and under it you’ll find why they ask it and one way you could answer in your own words.
Fresher level
1. Can you explain in simple words what GuardDuty does?
Why they ask this: Threat detection is part of every admin’s security work, so they want to know you understand how AWS spots attacks in an account.
How you might answer: GuardDuty is a threat detection service. It analyses CloudTrail events, VPC flow data and DNS data, along with some optional sources, and raises a finding when something looks like a compromise, and since each finding has a severity score I know which ones to look at first.
2. A colleague says you must turn on VPC Flow Logs before GuardDuty can work. Is that right?
Why they ask this: It’s a common misunderstanding, and knowing the answer stops teams setting up and paying for logs they think GuardDuty needs.
How you might answer: That’s not right. GuardDuty reads its own independent stream of flow logs, DNS logs and CloudTrail events, so you can turn it on without enabling VPC Flow Logs first.
3. Your team wants a message in their chat channel whenever GuardDuty finds something serious. How would you set that up?
Why they ask this: A finding nobody sees is useless, so they want to see you can connect detection to people.
How you might answer: I’d set up an EventBridge rule matching source aws.guardduty and detail-type GuardDuty Finding, with a severity filter so only the serious ones go through, and point it at SNS, a chat integration or our incident tool.
2–5 years experience
4. You set up an alert rule for GuardDuty findings, but it has never sent anything. How would you troubleshoot it?
Why they ask this: Silent alerting is dangerous because nobody notices it’s broken, so they want a clear order of checks across EventBridge, permissions and Regions.
How you might answer: I’d start with the rule’s MatchedEvents and FailedInvocations metrics. If nothing matched, I’d test the pattern with test-event-pattern, and if the invocations failed, I’d check the target’s resource policy, like the SNS topic policy or the Lambda permission. I’d also make sure GuardDuty is enabled in the Region where the findings happen, because the rule only sees events in its own Region.
5. It’s 2 a.m. and GuardDuty raises an InstanceCredentialExfiltration finding. What do you do?
Why they ask this: They want a calm, ordered incident response where you contain the problem, find out what happened and fix the root cause.
How you might answer: I’d identify the instance and its role and revoke the role’s active sessions with a deny on aws:TokenIssueTime. Then I’d go through CloudTrail to see what those credentials did, and isolate or replace the instance. After that I’d work out how the credentials leaked, which is often SSRF or IMDSv1, and enforce IMDSv2.
6. What’s the difference between GuardDuty and Security Hub, and why would you run both?
Why they ask this: Mixing up the security services leads to gaps in coverage, so they want to know you understand what each one is for.
How you might answer: GuardDuty detects threats, like someone using stolen credentials, while Security Hub CSPM checks configuration against standards and also brings findings from GuardDuty and other services together in one view with a common format. So I run both, because GuardDuty tells me something bad is happening and Security Hub shows me where we’re set up badly.
Senior level
7. You’re asked to design threat detection for an organization with 40 AWS accounts. How would you approach it?
Why they ask this: They’re looking for security architecture at scale, where new accounts are covered automatically and findings reach the right people fast.
How you might answer: I’d run GuardDuty and Security Hub with a delegated admin in a security account, auto-enabled for new accounts and every Region, and pick protection plans by workload. Findings would go to a central SIEM through EventBridge, routed by severity, and for high-confidence findings I’d have automated containment runbooks. I’d also go over the suppression rules every quarter so we’re not hiding real threats.
8. How would you prove to your manager that your security alerting actually works?
Why they ask this: Broken alerting is often only discovered during a real incident, so they want to see you test your controls and don’t assume they work.
How you might answer: I’d generate sample findings on a schedule in each account and Region and check end to end that the page or ticket turns up, and I’d alarm on FailedInvocations, and on zero MatchedEvents where we’d expect some. On top of that we’d run regular incident response exercises so people know what to do when an alert lands.
Quick quiz
Q1. What does GuardDuty need you to turn on before it can analyse VPC traffic?
- VPC Flow Logs
- Nothing
- A NAT gateway
- An agent on every instance
Show answer
B — GuardDuty reads its own copy of flow, DNS and CloudTrail data.
Q2. Why did the email stop arriving in break 2?
- GuardDuty was off
- The SNS topic policy did not allow EventBridge
- The pattern was wrong
- The email was unsubscribed
Show answer
B — FailedInvocations showed the delivery failure.
Q3. Which tool checks an event pattern against a sample event?
- aws events test-event-pattern
- aws sns publish
- aws guardduty get-findings
- aws logs filter
Show answer
A — It returns true or false without waiting for real events.
Q4. Which severity range is High?
- 1 to 3.9
- 4 to 6.9
- 7 to 8.9
- Only 10
Show answer
C — High findings usually page the on-call engineer.
Q5. What does Security Hub CSPM add?
- Threat detection only
- Compliance checks and aggregated findings
- Backups
- Encryption
Show answer
B — It runs standards and collects findings from many services.
Quick recap
- GuardDuty analyses AWS logs by itself and raises findings with a severity.
- EventBridge routes the findings, and you filter by severity.
- The SNS topic policy has to allow events.amazonaws.com, or delivery fails without any warning.
- Test patterns with test-event-pattern, and alarm on FailedInvocations.
- Security Hub CSPM adds compliance checks and gives you one place for findings.
Next lesson
Lesson 33: AWS Organizations and SCPs → Next you’ll create an organization, put guardrails in place with service control policies, and set up IAM Identity Center properly.
Further reading: AWS GuardDuty
Want to go deeper into AWS GuardDuty? Read What is Amazon GuardDuty? and Processing GuardDuty findings with Amazon EventBridge. You can also see the full plan for this course on the AWS Cloud Administration course page.
