npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@project-lakechain/opensearch-domain

v0.7.0

Published

Creates an OpenSearch domain with Cognito authentication.

Downloads

77

Readme

:package: OpenSearch Domain


Static Badge Static Badge


Overview

The OpenSearch Domain construct is an internal construct helper part of Project Lakechain and is mainly used for example purposes. It allows to easily create an OpenSearch Domain in a VPC with Cognito integration for authenticating users to the OpenSearch dashboard.

Usage

You can instantiate the construct in your CDK stack by specifying the VPC in which the domain should be created. This will create a new OpenSearch domain, a new Cognito user pool, a new security group for controlling access to the domain, and a new Cognito identity pool allowing users to authenticate with the domain's dashboard interface.

import { OpenSearchDomain } from '@project-lakechain/opensearch-domain';

export class Stack extends cdk.Stack {
  constructor(scope: Construct, id: string) {
    const openSearch = new OpenSearchDomain(this, 'Domain', {
      vpc: reference_your_vpc
    });
  }
}

Overriding domain parameters

You can provide your own domain parameters by partially specifying them in the opts property of the construct. For example, to customize the instance type for your domain, you can do the following :

You can override any property of the domain using the opts property.

import { OpenSearchDomain } from '@project-lakechain/opensearch-domain';

export class Stack extends cdk.Stack {
  constructor(scope: Construct, id: string) {
    const openSearch = new OpenSearchDomain(this, 'Domain', {
      vpc,
      opts: {
        capacity: {
          dataNodeInstanceType: 't3.small.elasticsearch'
        }
      }
    });
  }
}

Using an existing Cognito User Pool

If you already created a Cognito User Pool in your CDK stack that you would like this construct to use as an authenticating mechanism, you can simply pass your cognito.UserPool instance to the construct through its existingUserPool property :

import { OpenSearchDomain } from '@project-lakechain/opensearch-domain';

export class Stack extends cdk.Stack {
  constructor(scope: Construct, id: string) {
    const userPool = new cognito.UserPool(this, 'UserPool', {
      // ...
    });

    const openSearch = new OpenSearchDomain(this, 'Domain', {
      vpc,
      existingUserPool: userPool
    });
  }
}

Construct properties

When you create the OpenSearchDomain construct, it exposes the following properties that you can use in your code :

| Property | Type | Description | | --------------- | ------------------- | --------------------------------------------------------------------------------- | | domain | opensearch.Domain | The OpenSearch Domain created by the construct. | | userPool | cognito.UserPool | The Cognito User Pool created by the construct. | | securityGroup | ec2.SecurityGroup | The Security Group created by the construct for controlling access to the domain. |

Access Policies

This construct will create 2 access policies for the OpenSearch domain :

  • A policy allowing es:ESHttpGet and es:ESHttpPost access to the domain from any IAM principal in the current account that has access to the VPC in which the domain is deployed. This allows to decouple the identity-based access control from the resource-based access control on the domain. Note that other IAM principals (such as an AWS Lambda IAM role) will still need to have the required identity-based permissions control to access the domain.
  • A policy allowing the Cognito authenticated role full access to the domain, allowing users to manage the domain through the OpenSearch dashboard.