Building a Production RAG Ingestion Pipeline on AWS: Unstructured.io, S3 Vectors, and a Private VPC
Summary
A production RAG ingestion pipeline built entirely on AWS addresses limitations of Bedrock Knowledge Bases, such as its 50MB file cap and poor handling of complex documents. This event-driven architecture utilizes Unstructured.io, an open-source document parsing library, running on ECS Fargate for robust layout detection, OCR, and structured chunking with metadata like page numbers. Amazon Bedrock Titan generates embeddings, and Amazon S3 Vectors stores them, offering a pay-per-use alternative to OpenSearch Serverless's \$700/month minimum cost. The entire pipeline operates within a private VPC, ensuring data never leaves AWS, requiring 8 specific VPC endpoints costing approximately \$42 per month. DynamoDB tracks document status, and SQS handles retries. The Unstructured.io Docker image, at 6.6GB, necessitates setting ECS Fargate's ephemeral storage to 50GB. An end-to-end test processed 16 chunks in 87 seconds, demonstrating effective error handling and horizontal scalability.
Key takeaway
For MLOps Engineers building production RAG systems on AWS, consider this architecture to overcome Bedrock Knowledge Bases' limitations. By self-hosting Unstructured.io on Fargate and using S3 Vectors, you gain superior document parsing, enhanced security within a private VPC, and significantly lower vector storage costs compared to OpenSearch Serverless. Ensure your ECS tasks have sufficient ephemeral storage and provision all necessary VPC endpoints, including the often-missed S3 Vectors endpoint, to avoid runtime connection issues.
Key insights
Self-hosting Unstructured.io within a private AWS VPC enables robust, secure, and cost-effective RAG ingestion.
Principles
- Prioritize structured document parsing for RAG quality.
- Design event-driven pipelines for resilience.
- Secure data by keeping all processing within a private VPC.
Method
Documents trigger SQS messages, processed by ECS Fargate running Unstructured.io, then embedded by Bedrock Titan, and stored in S3 Vectors, with DynamoDB tracking status.
In practice
- Use "urllib.parse.unquote_plus" for S3 object keys.
- Set ECS Fargate "ephemeral_storage_gib=50" for Unstructured.io.
- Ensure boto3 >= 1.39.5 for S3 Vectors client.
Topics
- RAG Ingestion Pipeline
- Unstructured.io
- AWS VPC
- S3 Vectors
- ECS Fargate
- Document Parsing
- Bedrock Titan
Code references
Best for: AI Engineer, Machine Learning Engineer, MLOps Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.