Skip to content
GitHubXDiscord

Collection

The Collection resource allows you to create and manage AWS OpenSearchServerless Collections, which are designed to help you efficiently manage your search workloads without the overhead of traditional OpenSearch clusters.

Create a basic OpenSearchServerless Collection with required properties:

import AWS from "alchemy/aws/control";
const basicCollection = await AWS.OpenSearchServerless.Collection("basic-collection", {
name: "my-basic-collection",
type: "search", // Specify the type of collection
description: "A basic collection for search operations"
});

Configure a collection with standby replicas and tags for better management:

const advancedCollection = await AWS.OpenSearchServerless.Collection("advanced-collection", {
name: "my-advanced-collection",
type: "search",
description: "An advanced collection with standby replicas and tags",
standbyReplicas: "2", // Setting standby replicas for high availability
tags: [
{ Key: "Environment", Value: "Production" },
{ Key: "Team", Value: "Search" }
]
});

Create a collection that adopts an existing resource instead of failing if it already exists:

const adoptedCollection = await AWS.OpenSearchServerless.Collection("adopted-collection", {
name: "my-existing-collection",
adopt: true // Adopt existing resource
});

Create a collection and monitor its creation and update times:

const monitoredCollection = await AWS.OpenSearchServerless.Collection("monitored-collection", {
name: "my-monitored-collection",
type: "search",
description: "A collection to monitor creation and updates"
});
// Use the ARN and timestamps for monitoring
console.log(`Collection ARN: ${monitoredCollection.Arn}`);
console.log(`Created At: ${monitoredCollection.CreationTime}`);
console.log(`Last Updated At: ${monitoredCollection.LastUpdateTime}`);