October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Build an AWS RAG Stack with Terraform: S3, Bedrock and OpenSearch Serverless

A practical architecture and security guide to provisioning an S3-backed Bedrock Knowledge Base with OpenSearch Serverless, including Terraform caveats, IAM, networking, and lifecycle costs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can use Amazon S3 for source documents, Amazon Bedrock Knowledge Bases to manage ingestion and retrieval, and Amazon OpenSearch Serverless as the vector store in a Terraform-provisioned RAG system. The important caveat is that AWS’s published Terraform RAG pattern does not implement this exact combination: its example uses LangChain with Aurora PostgreSQL-Compatible. Treat the Bedrock Knowledge Bases and OpenSearch Serverless design as a separate implementation, and verify each Terraform resource and argument against the pinned AWS provider version you plan to use.

How the services fit together

The data path has three main parts: documents, managed ingestion and retrieval, and vector storage.

As an Amazon Associate I earn from qualifying purchases.

  1. Amazon S3 holds the source documents connected to the Knowledge Base as its data source.
  2. Amazon Bedrock Knowledge Bases manages the connected-data ingestion and retrieval flow. It transforms and indexes data for querying using the configured embedding model.
  3. Amazon OpenSearch Serverless stores vectors for the Knowledge Base. The storage configuration includes the collection, vector index, and field mappings.

These components have to agree on the embedding configuration and index field names. Field names are configuration choices, not universal Bedrock or OpenSearch constants. Set them consistently in the index and Knowledge Base rather than copying values from an unrelated example.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the implementation path deliberately

AWS documents both a Terraform RAG pattern and a managed Bedrock Knowledge Bases path, but they are not the same implementation. The Terraform pattern described by AWS uses LangChain and Aurora PostgreSQL-Compatible as its vector store. AWS identifies Bedrock Knowledge Bases and OpenSearch Service as alternatives; that does not make the published pattern a ready-to-deploy template for this exact stack.

Path What it provides What to plan for
AWS’s published Terraform RAG pattern An example using LangChain and Aurora PostgreSQL-Compatible. It is not an S3 data source plus Bedrock Knowledge Bases plus OpenSearch Serverless implementation.
Bedrock Knowledge Bases with OpenSearch Serverless A managed Knowledge Bases ingestion and retrieval flow with OpenSearch Serverless as the vector-store choice. Configure and secure the collection, index, mappings, service role, and network access for your deployment.

Choose based on the abstraction and services you want to operate. The managed Knowledge Bases route uses AWS’s ingestion and retrieval service; the published Terraform pattern demonstrates a different application and vector-store path. The available sources do not establish a quantitative performance or cost winner between them.

Plan the Terraform build around dependencies

Terraform can provision the infrastructure, but the available AWS example does not verify a complete Terraform module or provider version for the exact Bedrock Knowledge Bases and OpenSearch Serverless stack. Avoid treating resource names, arguments, or version constraints from the Aurora example as valid for this design. Pin a provider version, then check its current documentation for every resource and argument you intend to use.

  1. Define the target architecture. Decide which Region will host the resources, which embedding model the Knowledge Base will use, whether the OpenSearch Serverless collection will be private, and which S3 data source it will ingest.
  2. Design the vector index. Choose the index and field mappings and ensure they match the Knowledge Base storage configuration and embedding setup.
  3. Establish access controls. Create the Knowledge Base service role and the collection’s required security policies. Keep identity permissions, OpenSearch data access, and network reachability as separate checks.
  4. Provision and validate the integration. Use the pinned provider’s current resource documentation to implement the configuration. Verify that Bedrock can assume its role, access the selected model and S3 source, and reach and use the configured vector index.
  5. Test ingestion and retrieval. Confirm that the source data can be ingested and that a Knowledge Base query can retrieve from the configured store before relying on the system.

This is an implementation sequence, not a copy-paste Terraform recipe: the exact provider schema and a complete sample for this combination are not established here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scope the Bedrock service role and OpenSearch access

The Knowledge Base needs a service role with a trust relationship that allows Amazon Bedrock to assume it. Its permissions must cover the selected embedding model, the S3 data source, and the vector store. Grant only the operations and resources the deployment actually needs; do not use broad permissions simply to get past an access error.

Rank #3
SSTCOMM Modbus RS485 to WAN MQTT Gateway GT100-MQ-RS
  • Connect various PLCs, fieldbus instruments and devices to the Cloud Servers over WAN by MQTT protocol,
  • MQTT Gateway
  • Connect to Microsoft Azure, Amazon AWS, and more

OpenSearch Serverless also has a data access policy. AWS’s guidance calls for granting the role the required access to the relevant index. The role’s identity-based permissions and the collection’s data access policy are distinct controls: configuring one does not substitute for the other. Align the role, collection, index, and resource ARNs, then check each policy when access fails.

  • Bedrock cannot assume the role: check the role’s trust relationship.
  • Model or S3 access fails: check the service role’s permissions for the selected embedding model and data source.
  • Vector index access fails: check both the role’s identity-based permissions and the OpenSearch Serverless data access policy, including the index scope.

Choose a network posture and keep the controls separate

A private OpenSearch Serverless collection is reachable only through a PrivateLink VPC endpoint. Its network access policy must also allow Bedrock as a source service. A collection that is private but lacks the necessary endpoint or policy access will not be reachable through the intended path.

Network access, encryption policy, and data access policy serve different purposes. Review each independently rather than treating a collection policy as a single all-purpose security setting. An AWS tutorial uses a public network policy in its example; that example is not a production default. Decide deliberately whether the collection should be public or private for your environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Account for collection lifecycle and cost

AWS’s tutorial warns that idle OpenSearch Serverless collections accrue OCU-hour charges. The amount depends on the current pricing and deployment conditions; no current price figure is established here. Check pricing for the target Region and expected workload before deployment, and remove temporary collections and their associated policies after experiments using the cleanup steps for your setup.

What to verify before applying a plan

  • The pinned AWS provider supports the Terraform resources and arguments in your configuration.
  • The selected Region supports the services and model configuration you intend to use.
  • The S3 source, embedding model, vector index, field mappings, and Knowledge Base storage configuration are aligned.
  • The Bedrock service role has the correct trust relationship and appropriately scoped permissions.
  • The OpenSearch Serverless data access policy grants the role the required index access.
  • If the collection is private, the PrivateLink endpoint and network policy allow the required Bedrock access.
  • The deployment’s cost and cleanup plan account for OpenSearch Serverless collection lifecycle.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.