Skip to main content

Manage OpenSearch REST resources from AWS CDK.

Project description

Custom Resources Library for Amazon OpenSearch Service

An AWS CDK construct library to manage OpenSearch resources via CloudFormation custom resource. This is especially useful if you use fine-grained access control feature on OpenSearch, where you have to create resources such as role or role mapping via OpenSearch REST API.

architecture

Currently supported resources

You can manage any other REST resources via our low level API (ResourceBase class).

Usage

Instal it via npm:

npm install opensearch-rest-resources

Then you can create OpenSearch resources using Domain construct.

import { IVpc } from 'aws-cdk-lib/aws-ec2';
import { IRole } from 'aws-cdk-lib/aws-iam';
import { Domain } from 'aws-cdk-lib/aws-opensearchservice';
import { OpenSearchRole, OpenSearchRoleMapping } from 'opensearch-rest-resources';

declare const vpc: IVpc;
declare const backendRole: IRole;
declare const domain: Domain;

const role = new OpenSearchRole(this, 'Role1', {
    vpc,
    domain,
    roleName: 'Role1',
    payload: {
        clusterPermissions: ['indices:data/write/bulk'],
        indexPermissions: [
            {
                indexPatterns: ['*'],
                allowedActions: ['read', 'write', 'index', 'create_index'],
            },
        ],
    }
});

const roleMapping = new OpenSearchRoleMapping(this, 'RoleMapping1', {
    vpc,
    domain,
    roleName: 'Role1',
    payload: {
        backendRoles: [backendRole.roleArn],
    },
    removalPolicy: RemovalPolicy.RETAIN,
});
roleMapping.node.addDependency(role);

Limitation

Currently this library assumes your OpenSearch domain is configured such that:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "es:ESHttp*",
      "Resource": "domain-arn/*"
    }
  ]
}

Most of the above follow the current operational best practices of Amazon OpenSearch Service. If you want other configuration supported, please submit an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opensearch-rest-resources-0.0.8.tar.gz (98.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opensearch_rest_resources-0.0.8-py3-none-any.whl (96.6 kB view details)

Uploaded Python 3

File details

Details for the file opensearch-rest-resources-0.0.8.tar.gz.

File metadata

File hashes

Hashes for opensearch-rest-resources-0.0.8.tar.gz
Algorithm Hash digest
SHA256 48245344f588e1df2d135c965dcab65f4c0838ee2baeb7c3389889ac4ea77337
MD5 58b841bd66ebceffa2d4701b14b13314
BLAKE2b-256 741a86935ded346135942fc09b12d2b4e422100a7110d799b2ef91cac620edc5

See more details on using hashes here.

File details

Details for the file opensearch_rest_resources-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for opensearch_rest_resources-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b916f67beb753aa403d0c285d4bca8cfba53d09c6b8e95340e99d4340674fad4
MD5 e1460370fc1807467ac4a4a4b86c3a37
BLAKE2b-256 83439845f9a45d1f89ec1765000286c02dd6b0fc07ed34237716805ed11d5d6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page