A comprehensive AWS CDK TypeScript project for deploying and managing OpenSearch Serverless collections with best practices, security compliance, and automated resource tagging.
This project provides infrastructure as code (IaC) for AWS OpenSearch Serverless using AWS CDK. It creates vector collections with configurable types, standby replicas, and comprehensive CloudFormation outputs. The solution includes security best practices, automated resource tagging, and environment-specific configurations.
- Multi-Collection Support: Deploy multiple OpenSearch Serverless collections in a single stack
- Collection Types: Support for VECTORSEARCH, SEARCH, and TIMESERIES collection types
- Standby Replicas: Configurable standby replica settings (ENABLED/DISABLED)
- Security Compliance: Built-in AWS Solutions security checks using cdk-nag
- Resource Tagging: Automated tagging with environment, project, and owner information
- Environment Variables: Secure configuration management using environment variables
- CloudFormation Outputs: Comprehensive outputs for collection metadata
- TypeScript: Full TypeScript support with type safety
The project creates OpenSearch Serverless collections using the @cdklabs/generative-ai-cdk-constructs library, which provides the VectorCollection construct. Each collection is configured with:
- Collection name with resource prefix
- Collection type (VECTORSEARCH, SEARCH, TIMESERIES)
- Standby replica configuration
- Comprehensive CloudFormation outputs
- Node.js 22.x or later
- AWS CDK CLI v2.1019.1 or later
- AWS CLI configured with appropriate credentials
- TypeScript 5.8.3 or later
- Clone the repository:
git clone <repository-url>
cd aws-ow-opensearchserverless- Install dependencies:
npm install- Create a
.envfile in the root directory with the following variables:
APP_NAME=your-app-name
CDK_DEPLOY_REGION=us-east-1
ENVIRONMENT=development
OWNER=your-team-name
COLLECTION_NAMES=collection1,collection2
COLLECTION_TYPES=VECTORSEARCH,SEARCH
COLLECTION_STANDBY_REPLICAS=ENABLED,DISABLED| Variable | Description | Required | Example |
|---|---|---|---|
APP_NAME |
Name of the application | Yes | my-search-app |
CDK_DEPLOY_REGION |
AWS region for deployment | Yes | us-east-1 |
ENVIRONMENT |
Deployment environment | Yes | development, staging, production |
OWNER |
Team or owner responsible | Yes | data-team |
COLLECTION_NAMES |
Comma-separated collection names | Yes | vectors,documents,logs |
COLLECTION_TYPES |
Comma-separated collection types | Yes | VECTORSEARCH,SEARCH,TIMESERIES |
COLLECTION_STANDBY_REPLICAS |
Comma-separated standby replica settings | Yes | ENABLED,DISABLED,ENABLED |
- VECTORSEARCH: Optimized for vector similarity search operations
- SEARCH: General-purpose search functionality
- TIMESERIES: Optimized for time-series data
- ENABLED: Provides high availability with standby replicas
- DISABLED: Single instance without standby replicas
- Build the project:
npm run build- Watch for changes:
npm run watch- Run tests:
npm run test- Synthesize CloudFormation template:
npx cdk synth- Deploy to AWS:
npx cdk deploy- View deployment differences:
npx cdk diffAfter deployment, the stack provides the following outputs for each collection:
{collection-name}-oss-collection-name: Collection name{collection-name}-oss-collection-id: Collection ID{collection-name}-oss-collection-arn: Collection ARN{collection-name}-oss-collection-standby-replicas: Standby replica configuration{collection-name}-oss-collection-type: Collection type
aws-ow-opensearchserverless/
├── bin/
│ └── aws-ow-opensearchserverless.ts # CDK app entry point
├── lib/
│ ├── aws-ow-opensearchserverless-stack.ts # Main stack implementation
│ └── AwsOwOpensearchserverlessStackProps.ts # Stack properties interface
├── utils/
│ ├── apply-tag.ts # Resource tagging utility
│ ├── check-environment-variable.ts # Environment variable validation
│ ├── collection-standby-replicas-parse.ts # Standby replica parser
│ ├── collection-type-parse.ts # Collection type parser
│ └── vpc-type-parser.ts # VPC type parser
├── test/
│ └── aws-ow-opensearchserverless.test.ts # Unit tests
├── cdk.json # CDK configuration
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration- AWS Solutions Security Checks: Automated security compliance using cdk-nag
- Resource Tagging: Consistent tagging across all resources
- Environment Variable Validation: Secure configuration management
- Best Practices: Follows AWS CDK best practices and recommendations
Run the test suite to ensure everything works correctly:
npm run testThe project includes Jest-based unit tests for all utility functions and stack components.
aws-cdk-lib: AWS CDK core library@cdklabs/generative-ai-cdk-constructs: OpenSearch Serverless constructscdk-nag: Security compliance checksconstructs: CDK constructs librarydotenv: Environment variable management
typescript: TypeScript compilerjest: Testing framework@types/*: TypeScript type definitions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the existing issues in the repository
- Create a new issue with detailed information
- Include environment details and error messages
- v0.1.0: Initial release with OpenSearch Serverless collection support