aws-ai-reference-architectures
Six AWS AI reference architectures with ADRs, S/M/L cost, Well-Architected and Terraform
git clone https://github.com/fernando-moretes/app-aws-ai-reference-architectures.gitListen to guide
generated on playGenerated only on first play
Powered by Amazon Polly + OmniVoice
Six reference architectures for AI on AWS — each with a diagram, ADR-style decisions, cost at three scales, a Well-Architected review and a Terraform skeleton — written to be read in 10 minutes and ported into a real design doc.
Why this repository exists
Most AI-on-AWS examples fall into one of two extremes. On one side, the toy notebook: one file, no IaC, no IAM, no answer for whoever operates it at 2 AM. On the other, the 200-page enterprise white paper — impressive, and nobody reads it to the end before deciding. Neither helps when you need to close a design in a week.
This repository sits in the middle. Six opinionated reference architectures: detailed enough to support a real design, short enough to be read in 10 minutes each. All of them answer the same eight questions, in the same order — problem, components, diagram, decisions, cost, Well-Architected, trade-offs and Terraform skeleton. The repetition is deliberate: once you've read the first one, you know exactly where to look in the sixth.
What I wanted was material I could paste into a design doc without embarrassment. The trade-offs section says when not to use the pattern. The cost table shows the input assumptions, not just the final number. Decisions follow the MADR format, so they become ADRs with minor edits. The repo's dominant language is HCL because Terraform is precisely the part missing from most examples out there.
The six architectures
Each architecture lives in its own numbered folder under architectures/, with the same set of files. Since there are more than two options, the comparison goes in a table:
| # | Architecture | Pattern | Best for |
|---|---|---|---|
| 01 | RAG with Bedrock + OpenSearch | Retrieval-augmented generation | Internal Q&A over docs, knowledge bases |
| 02 | Multi-agent orchestration | Bedrock Agents + Step Functions | Long-running workflows that need durable state |
| 03 | Streaming AI inference | API Gateway + Lambda + Bedrock streaming | Chat UIs with token-level streaming |
| 04 | Event-driven AI processing | EventBridge + SQS + Lambda + Bedrock | Async classification, enrichment, moderation |
| 05 | Fine-tuning pipeline | SageMaker + S3 + MLflow | Custom models on top of foundation models |
| 06 | Secure agentic system | Bedrock Agents + Guardrails + VPC | Multi-tenant production agent with hard guardrails |
These six cover most of what I see in practice. 04 is the one that saves the most money in production — queuing Bedrock calls through SQS turns a spike into a backlog, and a backlog is what avoids throttling at 9 AM on Monday. 06 is the most underestimated: putting an agent behind a public endpoint without Guardrails and without a VPC is the mistake that shows up in the audit, not in the demo. If your case fits none of the six, open an issue with the use case — the repo grows by real case, not by service list.
How the repository publishes itself
One source (the six folders) feeds two destinations: the docs site on GitHub Pages and the static landing on Vercel. The security pipeline runs over everything.
- architectures/01..06 · diagrama, ADR, custo, WA, TF
- docs/ · MkDocs Material (strict)
- frontend/ · landing estática sem deps
- docs.yml · build strict + deploy
- CodeQL · Trivy · Gitleaks · dependency review
- GitHub Pages · site de documentação
- ▲ Vercel · preview por PR + produção
How each architecture is built
The format is the same across all six folders, and it's what makes the repo useful for review rather than just reading.
Decisions: 3 to 5 per architecture, in MADR — context, options considered, choice, consequences. A decision that doesn't list the rejected alternative isn't worth the space it takes; the alternative is what tells you whether the choice still holds in your context.
Cost: three S/M/L scales in USD/month, with the input assumptions written out — request volume, tokens per call, index size. The final number alone is misleading. The assumption is what you swap for your own volume and recompute before the budget meeting.
Well-Architected: the findings that matter across all six pillars, not a full checklist. It doesn't replace the Well-Architected Tool — run the formal Tool before any production launch. What's here is what I'd flag in a brownfield review.
Trade-offs: when to use it and, above all, when not to. 03 (streaming) is great for chat and terrible for batch. 05 (fine-tuning) only pays off once prompt engineering and RAG are exhausted.
Terraform: a skeleton with the resources and the wiring between them. No remote state, no production IAM policies, no imposed tagging convention. Names, networking and IAM are yours — that was a decision, not an omission, because every team has a different landing zone.
How to install and use
- 1
Clone and pick an architecture
git clone https://github.com/fernando-moretes/app-aws-ai-reference-architectures.gitand open the folder underarchitectures/that matches your case. Read it end to end once — it's 10 minutes — before copying anything. - 2
Serve the docs locally
The site is MkDocs Material. With Python 3 available:
pip install mkdocs-materialthenmkdocs serveat the root. CI runsmkdocs build --strict, so a broken link fails the build — the same command works for checking before you open a PR. - 3
Run the catalog landing
frontend/is a static page with no runtime dependencies; the lint, build andnpm auditscripts live in itspackage.json. To view it locally, serve the folder with any static server. - 4
Adapt the Terraform skeleton
Inside the architecture folder, point the provider at your account and region, add the remote-state backend and replace the placeholder IAM policies. Only then
terraform initandterraform plan. Do it in a sandbox account: the skeleton knows nothing about your landing zone. - 5
Port the decisions into your design doc
Copy the MADR decisions and the trade-offs section. Swap the cost table assumptions for your volume and recompute. That part — not the Terraform — is what carries the conversation with whoever approves the budget.
git clone https://github.com/fernando-moretes/app-aws-ai-reference-architectures.git
cd app-aws-ai-reference-architectures
# 1. Documentation site (MkDocs Material, same strict mode as CI)
pip install mkdocs-material
mkdocs build --strict && mkdocs serve # http://127.0.0.1:8000
# 2. Static catalog landing (no runtime deps)
cd frontend && npm install && npm run build && cd ..
# 3. Terraform skeleton — sandbox account only
cd architectures/01-rag-bedrock-opensearch
# edit provider/backend/IAM first, then:
AWS_PROFILE=sandbox terraform init
AWS_PROFILE=sandbox terraform planWhat the Terraform here does not do
The IaC is a skeleton by design: it shows resources and wiring, not a finished module. There is no remote state, IAM policies are a starting point and there is no tagging convention. A terraform apply without that adaptation creates generically named resources in an account that may not be the right one — and OpenSearch and SageMaker endpoints bill by the hour while they're up. Check aws sts get-caller-identity before any apply.
What runs in CI
A public portfolio without a pipeline is a promise, not proof. The cost of maintaining a reference repo isn't writing it — it's keeping it from rotting silently: a link that stops resolving, a dependency with a CVE, a secret committed by accident. That's why the repo carries automation for the parts that matter in public technical work:
- Frontend: lint, static build and
npm auditon every push. - Docs:
mkdocs build --strictand deploy to GitHub Pages. Strict mode is the difference between a reference site and a graveyard of links. - Security: CodeQL, dependency review on PRs, Trivy filesystem scan and Gitleaks for secrets. A leaked secret is the only hard gate; the rest informs.
- Maintenance: Dependabot for GitHub Actions and frontend dependencies.
- Vercel: preview per PR and production on
main, via Git integration — no deploy token lives in the repository.
OPERATIONS.md lists the full workflow and required secrets. CONTRIBUTING.md explains how to propose a new pattern or correct an existing one — cost and service-limit corrections are the most useful contribution, because that's what ages fastest.
Frequently asked questions
Why only six architectures?
Because six cover most of the AI workloads that cross my desk, and each one costs hours to keep current on cost, service limits and Well-Architected. Twenty stale patterns are worth less than six correct ones. New cases come in through issues, with the use case described.
Can I use the Terraform straight in production?
No. It's a skeleton: resources and wiring, no remote state, no production IAM, no networking adapted to your landing zone. Use it as a starting point and review every policy before the first apply outside a sandbox.
Are the cost numbers reliable?
They're estimates with explicit assumptions for S/M/L. The assumption is what matters — swap in your request and token volume and recompute. Bedrock model pricing changes often; checking the official table before presenting is mandatory.
Does this replace the AWS Well-Architected Tool?
No. The WA sections are the salient findings I'd flag in a review. Before any production launch, run the formal Tool — that's what produces the auditable record.
References
Verdict
Use this repository when you need to close an AI-on-AWS design in days, not weeks, and want to start from decisions with recorded alternatives, cost with explicit assumptions and a list of what not to do. It's for the architect or tech lead writing the design doc, and for whoever is reviewing an existing system against Well-Architected. Don't use it if you're after Terraform modules ready to apply, or an exhaustive taxonomy of patterns — the repo is opinionated by choice and covers six cases that recur in practice. The trade-off is clear: fewer patterns, each one maintained; the cost of maintaining is what decides what gets in.
Architecture, AWS, AI and market deep dives — straight to your inbox. Free.
No spam · unsubscribe anytime