Your AWS account, drawn: a read-only agent that turns live inventory into editable draw.io diagrams

An AI agent on Amazon Bedrock AgentCore that reads a live AWS account through a read-only cross-account role and returns an editable draw.io diagram. It can scope by tag or resource group, adds connections AWS doesn’t record, and keeps the model out of the facts.

Cloud @ Sudo | 14x AWS Certified | 2x Claude Certified | 2x Oracle | 2x CNCF(KCNA , KCSA)

Why I built this

In short, this tool reads a running AWS account and hands back an editable draw.io file. The code is public at  github.com/aquavis12/inventory2drawio .
I look after 30 to 40 customer AWS accounts, and they change faster than I can draw them. A hand-drawn diagram was out of date within weeks. Then AWS archived Workload Discovery on AWS in August 2026, which removed the tool that could have drawn them for me.
So I built the thing I wanted. I pick an account and a Region, optionally narrow it down by tag or resource group, optionally upload a Markdown file describing how requests flow, and about 12 seconds later I have an editable  .drawio  file.
It costs under a fifth of a cent. Everything in it exists in the account. Nothing is created, changed, or invented, and that was the rule I cared about most.

The LMS study site, drawn from live inventory and opened in draw.io.

What it has to do

I wrote these down before I wrote any code, and they're still what I judge it by:
  1. Read many accounts without write access anywhere.
  1. Give the same diagram for the same inputs.
  1. Let someone who isn't an AWS expert scope a drawing ("the orders app", "just S3") without learning tag syntax.
  1. Produce an editable file, not a picture.
  1. Show connections that AWS doesn't record.

What it draws

Technology

Piece
What it does here
Amazon Bedrock, Nemotron 3 Super
The model. It writes the explanation and handles the scope question. It doesn't touch the facts.
AgentCore Runtime, Gateway, Memory
Runs the agent, exposes the two Lambda tools over MCP with IAM auth, and remembers per-customer preferences
AWS Lambda, Amazon S3
 collect_inventory  and  render_drawio , plus the profiles, skills, graphs, and diagrams
Streamlit
The UI on my own machine, with prompt templates and flow-file upload
The customer side is deliberately small. The customer deploys one CloudFormation template,  customers/customer-role.yaml , in their own account. It creates a read-only IAM role,  inv2drawio-readonly , that trusts my collector's account and requires an external ID. The collector assumes that role cross-account with STS. That cross-account IAM role is what makes the connection possible, and it's the only thing installed in their account.

Architecture




Here's the whole thing on one page. Two Lambda tools sit behind AgentCore Gateway. The collector assumes the read-only role in the customer account and writes the inventory graph to S3. The renderer lays that graph out and writes the  .drawio  file, which the UI downloads directly.

The agent UI: pick the customer and Region, scope by tag, and ask.
The only writes the tool makes go to its own work bucket in the tooling account. Nothing is written to a customer account. Permissions are set in one place. Each customer account gets one read-only role, and the collector only reads the Regions listed in that customer's  profile.json . The collector Lambda enforces that list. I'd use the repository's read-only policy or ViewOnlyAccess, not ReadOnlyAccess, which can also read data such as S3 objects.

Why an agent, and why code does most of the work

I didn't want a model in charge of this, and most of the system isn't. The model handles only the jobs where the input is messy English and the output is prose:
Job
Why code can't do it alone
Turn "just my S3 buckets" or "the orders app" into  only_services ,  tag_filter  or  resource_group 
The input is free text; the tool schema is the contract
Decide when not to draw (greetings, follow-up questions)
Also free text, but the check runs on your words first
Match flow-file steps ("the site calls vr-activity-api") to real resource names
Fuzzy name matching
Explain the result in request order
Prose
The explanation covers how a request travels through the drawn resources, what was hidden, and the findings. The collector computes the findings, and the model only rewords them. The agent is never the source of a fact.

Whether to draw at all is also decided in code, in  agent/intent.py . The UI attaches the sidebar scope to every message, so the check runs on your own words. A message with no drawing intent gets a chat reply with no tools, scope, or flow text attached. Keyword matching is crude and can misread an unusual phrasing, but it never draws by accident.

Scope works the same way. The collector applies  only_services  in code, and a prompt rule says nothing is hidden when it's used.

Why Lambda? AgentCore Gateway can call Lambda functions as tools. Each tool is stateless, authenticated with IAM, and deployed once. The collector has to run somewhere that can assume a role in a customer account, and that role is the only access the tool gets.

The rule: code decides, the model explains

Every problem I hit came from letting the model do something code should do. Here's the split I ended up with:
Job
Done by
What exists and how it connects
Collector Lambda
Where boxes go
Layout code: no overlaps, same structure every run
Which customer and Region to read
The app, injected into every tool call; the model can't change them
The download link
Passed beside the answer, never through the model
Flow links
Only the Markdown file, checked against real resources
Scope, what to hide, the explanation
The model

How the inventory works

If you're going to build this yourself, spend your time here. The collector reads one Region, plus the global CloudFront and Route 53 services, using a read-only role. It tries four sources, in this order.
  1. Dedicated collectors for about 20 resource types, such as VPCs, subnets, route tables, EC2, load balancers and their targets, RDS, Lambda and its event sources, API Gateway, DynamoDB, SQS, SNS, Cognito, ACM, S3, CloudFront, and Route 53. These give the placement and connections, so they run first.
  1. AWS Resource Explorer, if the customer already has it on. It's the most complete source, but it has to be turned on per Region with an aggregator index. Plenty of customers won't do that just so I can draw a diagram.
  1. Otherwise, Cloud Control plus the Resource Groups Tagging API. Cloud Control covers 30 common types and needs no setup. It needs a list permission per service, so a missing permission skips that type, and the skip is named in the notes.
  1. A noise filter. IAM, logs, KMS, task-definition revisions, and AWS-created resources get dropped and counted, so they don't clutter the picture.  include_services  overrides that.

The collector also adds the connections the APIs don't state outright. API Gateway connects to Lambda and Cognito. CloudFront connects to its origins and certificate. Event sources and SNS subscriptions connect to Lambda. A Lambda connects to the tables, buckets, queues, and topics named in its environment variables, compared in memory and never stored. A subnet counts as public only if its route table sends  0.0.0.0/0  to an internet gateway.
With a tag or resource group, only matching resources are drawn. The collector leaves out plumbing and stays strict about scope.

Adding the flow AWS can't see

AWS knows what exists. It mostly doesn't know who talks to whom. These are the connections I had to describe by hand:
  • A browser or mobile client calling API Gateway or CloudFront. No resource owns the caller, so there's nothing for AWS to record.
  • A Lambda calling an API by URL or SDK. IAM and resource configuration don't record call paths. Only environment variables that name a table, bucket, or queue give a hint, and only on an exact match.
  • Scheduled or manual jobs, and anything outside AWS, like SaaS tools or on-premises systems.
  • Tags and names that suggest a relationship without establishing one.
AWS doesn't provide these because a relationship is a property of runtime traffic and code, not of the resource settings its APIs expose. VPC Flow Logs or X-Ray could show some of them, but only if they were switched on before you needed the answer.
So I describe the flow in a few lines of Markdown:
1. The site sends activity and quiz results to vr-activity-api.
2. vr-activity-fn stores submissions in vr-submissions.
3. Every evening, vr-activity-fn publishes a summary to vr-daily-submissions.
The agent maps each step to real resources. The renderer draws a dashed, labelled link only when both ends exist. If no flow file is sent, described links are dropped entirely. Steps that name people or outside systems get skipped, and the reply lists them so nothing disappears silently.

Customers, configuration and install

Each customer has two files.  profile.json  holds the account, role, external ID, and allowed Regions. The Lambda reads it, and it never goes through the model.  skill.md  is plain-language background for the agent: which tag scopes an app, which environment is the default, what to hide, and how to title the diagram. The agent passes only a customer ID. The Lambda assumes the  inv2drawio-readonly  role in that account and refuses any Region that isn't approved.
The customer dropdown reads the  customers/  folder in the work bucket. There's no hard-coded list and no SSO. The tool uses your own local AWS identity.
Why S3 and not DynamoDB? Because this is a handful of small, rarely changed, human-edited files. S3 gives me versioning and easy review. DynamoDB would add complexity at this scale and buy nothing.

Install once, draw many accounts. "Install once" means two things. You deploy the tool in one tooling account. Then you deploy  customers/customer-role.yaml  in each customer account, which creates the read-only role. That's it. My live runs used my own account. The cross-account path is covered by tests against two mocked accounts.

Layout and C4

Layout is code, not the model. The renderer groups resources by VPC, subnet, and Availability Zone, then by resource group. It places services in tiers from left to right: entry, API, compute, and data. The same input gives the same file. The model chooses only the scope and the  hide_ids , so for a given scope the result is repeatable.
Line routing is code too. draw.io's automatic routing ran lines through icons, so the renderer routes each connection itself. A line leaves one side of its icon, runs along the free lanes between icons and rows, and enters the side facing its source. The path is the shortest orthogonal route, with a penalty for each bend. A test checks every written segment against every other icon. On a dense layout of 60 icons and 80 connections, all 79 routed lines came out clear, in 0.05 s. Diagrams with more than 70 icons, or connections with no free path, fall back to draw.io's routing. Lines can still cross group borders and each other.
Resources that are connected to the scope but outside it go in a dashed "Connected, not in scope" box, so they don't look like part of the tagged application.


Memory

I told the agent once to leave out the ACM certificate. In a new conversation, without repeating myself, the next diagram left it out, and the agent recalled the preference when I asked. The test recorded 11 events and 9 long-term memories with 0 errors. Retrieval averaged about 230 ms.




A new conversation recalls the preference, and the next diagram follows it.


*AgentCore Memory in CloudWatch: 11 events, 9 long-term memories extracted, no errors. *

Memory cost for the whole test: under one cent, $0.0095 in total.

Results

The LMS resource group,  vishnu-lms-study-site , is the AWS Resource Group defined by the tags  app=lms  and  createdby=vishnu . One request scoped to it took about 12 seconds: 0.9 s for inventory, 7.9 s for rendering, and 11.1 s for the answer. It used 9,928 input and 262 output tokens, about $0.0017 at the Nemotron 3 Super rates listed by third-party trackers ( source ).




Model invocations in CloudWatch GenAI Observability across the day's test runs.

Why not just use the AWS MCP Server?

If you're one engineer exploring one account, an AI assistant with the AWS MCP Server and the draw.io MCP server is less work, and I'd use it myself. If you're drawing many customer accounts for a team, this build gives you the same API calls and layout every run. It keeps an 820-byte summary in the model's context instead of raw API output. It gives each customer one read-only role and a UI anyone can use. The two also combine: an assistant with the draw.io MCP server can edit what this tool produces.

What's next

This tool draws what exists. A second project,  tfimport , does the opposite job: it finds AWS resources that no infrastructure-as-code tool manages and imports them into Terraform. It runs on AgentCore too, with a Streamlit UI.

The plan is one orchestrator agent over both. A single request would return the diagram and the Terraform code for the same resources. That's a future run, not something I've built yet.

Clean up

Delete the tooling resources with  scripts/teardown.sh  in the repo. It is a dry run until you set  DRY_RUN=0 , so run it once to see the commands first. Set the IDs and names of your own resources:
export REGION=us-east-1 WORK_BUCKET=inv2drawio-work-<ACCOUNT_ID>
export RUNTIME_ID=<runtime-id> GATEWAY_ID=<gateway-id> TARGET_IDS="<target-id-1> <target-id-2>" MEMORY_ID=<memory-id>
bash scripts/teardown.sh # prints the commands
DRY_RUN=0 bash scripts/teardown.sh # deletes them
In each customer account, delete the CloudFormation stack that created  inv2drawio-readonly . The IAM roles the tool created on the tooling side are not deleted by the script; remove them after the resources above.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article