Skip to main content

Stock Market Analysis Chatbot — Private VPC

A variant of the Stock Market Analysis chatbot that deploys the AgentCore Runtime inside a fully private VPC with no NAT gateway. All AWS service traffic is routed through VPC endpoints.

What's Different from the Public Version

AspectPublic VersionThis Version
Network modePUBLICVPC (isolated subnets)
NAT gatewayNone neededNone (no internet egress)
AWS service accessVia internetVia VPC endpoints
AgentCore ENIsNot in VPCPlaced in private isolated subnets
CostLowerHigher (VPC endpoint hourly charges)

Architecture

┌─────────────────────────────────────────────────────────────┐
│ VPC (10.0.0.0/16) — Isolated Subnets Only │
│ │
│ ┌──────────────┐ ┌──────────────────────────────────┐ │
│ │ AgentCore │──▶│ VPC Endpoints │ │
│ │ Runtime ENIs │ │ • S3 (gateway + interface) │ │
│ └──────────────┘ │ • ECR / ECR Docker │ │
│ │ • Bedrock / Bedrock Runtime │ │
│ │ • CloudWatch Logs / Monitoring │ │
│ │ • STS, KMS │ │
│ └──────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘

CloudFront ──▶ S3 (Frontend)
User ──▶ AgentCore Endpoint (HTTPS) ──▶ Bedrock (via VPC endpoint)

Prerequisites

  • AWS CLI v2 configured with credentials
  • Python 3.11+
  • Node.js 18+
  • CDK bootstrapped: npx cdk bootstrap

Deployment

cd examples/chatbot/stockmarket-analysis-private-vpc
bash deploy.sh

Or step by step:

bash init.sh
source .venv/bin/activate
cd frontend && npm ci && npm run build && cd ..
cdk deploy --require-approval never --outputs-file cdk-outputs.json

VPC Endpoints Created

EndpointPurpose
S3 (gateway + interface)Asset uploads, session storage, ECR image layers
ECR / ECR DockerPulling the AgentCore container image
Bedrock / Bedrock RuntimeModel invocation
CloudWatch Logs / MonitoringObservability
STSRole assumption
KMSEncryption operations

Cleanup

cdk destroy