Skip to content

Collection

Source: src/AWS/OpenSearchServerless/Collection.ts

An Amazon OpenSearch Serverless collection — a group of OpenSearch indexes that scales OpenSearch Compute Units (OCUs) automatically. A collection of type VECTORSEARCH is the vector store required to back an Amazon Bedrock Knowledge Base.

A collection requires a matching encryption SecurityPolicy to exist before creation, plus a network security policy and a data AccessPolicy to be reachable and usable. Creation is asynchronous — the provider polls (bounded, ~5 minutes) until the collection reaches ACTIVE.

import * as AWS from "alchemy/AWS";
const encryption = yield* AWS.OpenSearchServerless.SecurityPolicy("Enc", {
policyName: "kb-enc",
type: "encryption",
policy: {
Rules: [{ ResourceType: "collection", Resource: ["collection/kb"] }],
AWSOwnedKey: true,
},
});
const network = yield* AWS.OpenSearchServerless.SecurityPolicy("Net", {
policyName: "kb-net",
type: "network",
policy: [
{
Rules: [
{ ResourceType: "collection", Resource: ["collection/kb"] },
{ ResourceType: "dashboard", Resource: ["collection/kb"] },
],
AllowFromPublic: true,
},
],
});
const collection = yield* AWS.OpenSearchServerless.Collection("KB", {
collectionName: "kb",
type: "VECTORSEARCH",
});
// collection.collectionEndpoint is the aoss data-plane endpoint
const collection = yield* AWS.OpenSearchServerless.Collection("Search", {
collectionName: "logs",
type: "SEARCH",
description: "application logs",
});