
Centralize AWS Security Agent findings and query them with Amazon Athena and Amazon Quick Suite
This tutorial shows you how to automatically centralize AWS Security Agent penetration test findings in Amazon S3, query them with Amazon Athena, and visualize them in an Amazon Quick Suite dashboard. You deploy a single AWS CloudFormation stack, send findings to a central store, and then run SQL and build charts that span every penetration test in your account.
AWS Security Agent is a frontier agent that proactively secures your applications throughout the development lifecycle across all your environments. It performs on-demand penetration testing customized to your application, discovering and reporting verified security risks. After a test is complete, the results are available in the AWS Security Agent web application, where you can review each finding and generate a PDF.
The web application is ideal for reviewing a single run. But as you run more penetration tests, across more applications, you often want to see everything in one place: which applications carry the most critical risk, how a finding count trends run over run, and how open findings are distributed across risk levels. This tutorial builds that central view. Findings are exported to Amazon S3 as they complete, cataloged with AWS Glue, queried with Amazon Athena, and visualized in Amazon Quick Suite.
What you build
The solution is a CloudFormation stack that captures findings without any manual export step. When a penetration test job starts, the stack waits for it to finish and then writes the findings to a central S3 bucket that Athena and Quick Suite read from.

The flow is event driven:
- AWS Security Agent emits a StartPentestJob management event to AWS CloudTrail when a penetration test job begins.
- An Amazon EventBridge rule matches that event and starts a Step Functions state machine, passing along the agentSpaceId, pentestId, and pentestJobId.
- The state machine polls the job with BatchGetPentestJobs on an interval (one hour by default) until the job reaches a terminal state.
- When the job status is COMPLETED, the state machine invokes a Lambda function that pages through ListFindings and BatchGetFindings and writes the findings to Amazon S3 as newline-delimited JSON.
- An AWS Glue database and table define the schema over that data, an Amazon Athena workgroup and named query let you run SQL, and Amazon Quick Suite turns the results into a dashboard.
The state machine below runs once per job: it polls, branches on the terminal status, and exports on completion.

Findings are stored as newline-delimited JSON in a Hive-style, partition-ready layout:
findings/source_type=pentest/agent_space_id=as-.../config_id=pt-.../job_id=pj-.../findings.jsonl The Glue table scans the findings/ prefix recursively, so the queries in this tutorial work with no partition management. At larger scale you can move to Glue partitions or partition projection over the same layout without moving any data.
Prerequisites
Before you begin, make sure that you have the following:
- AWS CLI version 2, installed and configured with credentials for the account and Region where AWS Security Agent is set up. This tutorial uses us-east-1.
- AWS Security Agent configured with at least one Agent Space and one penetration test. To see findings right away, have a penetration test that has already produced a COMPLETED job.
- Permissions to deploy the stack. The template creates IAM roles, a Lambda function, a Step Functions state machine, an S3 bucket, Glue and Athena resources, and an EventBridge rule, so you deploy with the CAPABILITY_IAM capability.
- A CloudTrail trail logging management write events in this Region. EventBridge only receives the StartPentestJob event if a trail is capturing management events. Most accounts already have an organization or account trail. If you don't have one, you can have the stack create a trail (described later).
- An Amazon Quick Suite (formerly Amazon QuickSight) subscription and administrator access, which you need to grant Quick Suite access to Athena, AWS Glue, and Amazon S3.
Part 1: Deploy the solution
Follow the steps on the sample-security-agent-centralized-findings repository to deploy the solution.
Review what was created
After the stack finishes, list its outputs. You reference several of these values in the next steps.
aws cloudformation describe-stacks \ --region us-east-1 \ --stack-name securityagent-findings \ --query 'Stacks[0].Outputs' \ --output tableNote the StateMachineArn, FindingsBucketName, AthenaWorkGroup, and GlueDatabaseName values.
Part 2: Capture findings
There are two ways findings get into the bucket: automatically, for jobs that start after you deploy the stack, and manually, so you can backfill jobs that have already been completed.
The automatic path
Once the stack is deployed, you don't need to do anything for new runs. The next time a penetration test job starts, AWS Security Agent emits the StartPentestJob event, the EventBridge rule starts the state machine, and the findings are exported to S3 after the job completes. Because the state machine polls on an interval (one hour by default), findings appear in the bucket after the job finishes, not immediately.
Import an existing job
To backfill findings from a job that already completed, start the state machine yourself. This skips the CloudTrail and EventBridge path and runs the poll-and-export directly. You need the Agent Space ID, penetration test ID, and job ID, which you can look up with the AWS CLI.
First, list your Agent Spaces and note the agentSpaceId.
aws securityagent list-agent-spacesNext, list the penetration tests in that Agent Space. For <AGENT_SPACE_ID> enter the agentSpaceId from the previous command, and note the pentestId.
aws securityagent list-pentests \ --agent-space-id <AGENT_SPACE_ID>Then list the jobs for that penetration test and note the pentestJobId of a job with a status of COMPLETED.
aws securityagent list-pentest-jobs-for-pentest \ --agent-space-id <AGENT_SPACE_ID> \ --pentest-id <PENTEST_ID>Now start the state machine with those three values. Use the StateMachineArn from the stack outputs.
aws stepfunctions start-execution \ --state-machine-arn "<StateMachineArn>" \ --input '{ "agentSpaceId": "as-c1fdb673-2010-4059-b7b0-EXAMPLE", "pentestId": "pt-47fba927-b35b-4e10-8020-EXAMPLE", "pentestJobId": "pj-1fe258e3-95f1-4337-93aa-EXAMPLE" }'Because you started from a job that is already COMPLETED, the state machine exports the findings on its first poll.
Verify the findings in S3
Confirm that the findings were written. Use the FindingsBucketName from the stack outputs.
aws s3 ls s3://securityagent-findings-findings-<account-id>-us-east-1/findings/ --recursiveThe following is example output. Each completed job produces one findings.jsonl object under its own partition path.
findings/source_type=pentest/agent_space_id=as-c1fdb673.../config_id=pt-47fba927.../job_id=pj-1fe258e3.../findings.jsonl 
Part 3: Query the findings in Athena
With findings in S3 and the Glue table in place, you can query across every job you have exported.
Step 1: Open the workgroup
Open the Athena console, choose Workgroup at the top, and select the securityagent-findings-findings workgroup (the AthenaWorkGroup output value). The workgroup already points its query results to s3://securityagent-findings-findings-<account-id>-us-east-1/athena-results/, so you don't need to configure a results location.

Step 2: Run the sample query
The stack includes a saved query named securityagent-findings-high-risk-findings. On the Saved queries tab, open it and choose Run, or paste the following into the editor.
SELECT sourcetype, pentestjobid, pentestid, findingid, name, risklevel, riskscore, confidence, validationstatus, status, createdatFROM "securityagent-findings_security_agent"."findings"WHERE sourcetype = 'pentest' AND risklevel IN ('CRITICAL', 'HIGH') AND status = 'ACTIVE'ORDER BY CASE risklevel WHEN 'CRITICAL' THEN 1 WHEN 'HIGH' THEN 2 ELSE 3 END, createdat DESCLIMIT 100;This returns the open, high-severity findings across every exported job, with CRITICAL findings first and the most recent first within each risk level.

Step 3: Track findings over time for one penetration test
Because each run of a penetration test adds a new job, you can roll findings up per job to see how counts move from run to run. For pentestid, use a pt-... value from your account.
SELECT pentestjobid, min(createdat) AS first_finding_at, count(*) AS total_findings, count_if(risklevel = 'CRITICAL') AS critical, count_if(risklevel = 'HIGH') AS high, count_if(risklevel = 'MEDIUM') AS medium, count_if(risklevel = 'LOW') AS low, count_if(status = 'ACTIVE') AS activeFROM "securityagent-findings_security_agent"."findings"WHERE sourcetype = 'pentest' AND pentestid = 'pt-47fba927-b35b-4e10-8020-EXAMPLE' AND confidence = 'HIGH'GROUP BY pentestjobidORDER BY first_finding_at;Part 4: Visualize the findings in Amazon Quick Suite
Athena is great for ad hoc SQL. To share a dashboard with your team, connect Amazon Quick Suite to the same Athena workgroup and Glue table.
Step 1: Give Quick Suite access to Athena, AWS Glue, and Amazon S3
Quick Suite needs permission to run Athena queries, read the AWS Glue Data Catalog, and read from (and write results to) the findings bucket.
- Open the Amazon Quick Suite console.
- Choose your account name in the upper right, and then choose Manage account.
- Under Shortcuts, choose AWS resources (Allow connections to first-party services). This opens the Quick access to AWS services page.
- Under Allow access and autodiscovery for these resources, select Amazon Athena and AWS Glue Data Catalog.
- When you enable Athena, an Amazon Athena permissions dialog appears; choose Next to grant the S3 buckets Athena uses now, or Skip to grant S3 separately in the next step.
- Select Amazon S3, choose Select S3 buckets, and add the findings bucket,
securityagent-findings-findings-<account-id>-us-east-1. Select the bucket's read checkbox and its Write permission for Athena Workgroup checkbox so Quick Suite can write query results to the workgroup's results location. If the bucket isn't in the linked list, open the S3 buckets you can access across AWS tab and add it by name.
- Choose Save.
Note: The write permission is what lets Quick Suite use the solution's Athena workgroup, which enforces its results location at
s3://securityagent-findings-findings-<account-id>-us-east-1/athena-results/ . Enabling AWS Glue Data Catalog is what lets Quick Suite list the securityagent-findings_security_agent database when you create the dataset.
Step 2: Create an Athena dataset
- In the left navigation, choose Data, and then choose Create dataset.
- Choose Create data source, select Amazon Athena, and choose Next.
- For Data source name, enter a name such as security-agent-findings. For Athena workgroup, choose securityagent-findings-findings. Choose Validate connection, and then choose Create data source.
- In Choose your table, select the catalog (AwsDataCatalog), the database securityagent-findings_security_agent, and the table findings. Choose Select.

Step 3: Choose SPICE or direct query
Quick Suite asks whether to import the data into SPICE or query Athena directly:
- Import to SPICE caches the data in Quick Suite's in-memory engine for fast, low-cost dashboards. Schedule a refresh so new findings show up.
- Directly query your data always reads the latest findings from Athena at the cost of a query per interaction.
Important: The findings table includes two complex columns — coderemediationtask (a struct) and codelocations (an array of structs) — that SPICE cannot ingest. If you choose Import to SPICE, preparation fails with "Unable to prepare this table." Either choose Directly query your data (used in this tutorial), or choose Edit/Preview data first and exclude those two fields before importing to SPICE.
Make your choice and then choose Visualize.
Step 4: Build the visuals
The analysis opens with an empty AutoGraph visual. Click a field in the Data pane and Quick Suite adds it to the active visual and picks a chart type automatically. To add another visual, choose Add Visual on the toolbar and then click the field you want.
Build visuals that answer the questions your team cares about. A few that map well to the findings schema:
- Findings by risk level — click risklevel to get a Count of Records by Risklevel bar chart (CRITICAL, HIGH, MEDIUM, LOW, INFORMATION, UNKNOWN).
- Risk type breakdown — add a second visual and click risktype to see the distribution across vulnerability classes (for example, SQL_INJECTION, PRIVILEGE_ESCALATION, SERVER_SIDE_REQUEST_FORGERY).
- Findings by application — add a visual and click agentspaceid (or pentestid) to see which applications carry the most findings.
- Open vs. resolved — a chart on status (for example, ACTIVE) filtered to high-confidence findings.
To keep low-confidence findings from skewing the view, add a filter on confidence (for example, HIGH and MEDIUM).

Add a findings-over-time trend
To trend findings by day, first derive a date field. In the Data pane choose Calculated field, name it Finding day, and enter:
substring({createdat}, 1, 10)This extracts the YYYY-MM-DD portion. Now add a line chart with Finding day on the X-axis; Quick Suite plots the count of findings per day. Because the central store holds findings from every run across all your applications, this reveals how findings trend over time — not just within a single job.

Step 5: Publish and share the dashboard
When the analysis looks right, choose Publish in the upper right, keep New dashboard, give the dashboard a name such as AWS Security Agent findings, and choose Publish dashboard. Then use Share to give the users or groups in your account access.

Cleanup
To remove the solution, delete the stack.
aws cloudformation delete-stack \ --region us-east-1 \ --stack-name securityagent-findingsDeleting the stack removes the centralized reporting resources only. It does not affect your Agent Space or penetration test configuration. The S3 buckets are retained on stack deletion so you don't lose exported data. Empty and delete them manually if you no longer need the findings. In Quick Suite, delete the dataset and dashboard if you created them only for this tutorial.
Note: The exported findings include finding descriptions, reasoning, and reproduction steps. Treat this data as sensitive and follow your organization's data-handling processes.
Cost
The solution uses serverless resources (EventBridge, Step Functions, Lambda, S3, Glue, and Athena), and for most customers the cost is less than $1, not counting AWS Security Agent itself and Amazon Quick Suite. Athena is billed per data scanned, and Quick Suite is billed per user (and by SPICE capacity). For details, review AWS Security Agent pricing , Amazon Athena pricing , and Amazon Quick Suite pricing .
Conclusion
In this tutorial, you deployed a CloudFormation stack that centralizes AWS Security Agent penetration test findings without a manual export step. You saw how an EventBridge rule and a Step Functions state machine capture findings as jobs complete, how to backfill an existing job by starting the state machine yourself, and how the findings land in Amazon S3 in an Athena-friendly layout. You then queried the findings across every run with Amazon Athena and built a shareable dashboard in Amazon Quick Suite.
From here, you can extend the queries and visuals to fit your reporting, add filters for specific applications or risk types, and schedule SPICE refreshes so the dashboard stays current. As AWS Security Agent adds capabilities such as code review, the same S3 layout and sourceType field let you bring that data into the same central store.
New AWS Security Agent customers receive a free trial. For more information, visit the AWS Security Agent pricing page . For more details on the API, review the AWS Security Agent API Reference .
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article