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

Install 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: role.roleName,
    payload: {
        backendRoles: [backendRole.roleArn],
    },
    removalPolicy: RemovalPolicy.RETAIN,
});

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.12.tar.gz (100.5 kB view details)

Uploaded Source

Built Distribution

opensearch_rest_resources-0.0.12-py3-none-any.whl (98.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for opensearch-rest-resources-0.0.12.tar.gz
Algorithm Hash digest
SHA256 ce5d9f706b42dc8af09b51f1751493fe7ea5ebaeb73f1f5ea4935a604cbb233a
MD5 cb3e5caaba8f2a53d804f44064454fb4
BLAKE2b-256 23bb9262ac2307b91f8b48a38f3a9ea7757022a88623c0aec51d9d909459511c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opensearch_rest_resources-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 3454786dfb51f851d77bdd072b9e597457b41e66e66a0bf6ea63b6c158f8d0e7
MD5 ef5bbec9be36d88b735ba2a0b21218c0
BLAKE2b-256 cf05c62aa46f0504f61bbf1e5f4ffa6cedfa705c5dbb926c77ccb2e2a78363d9

See more details on using hashes here.

Supported by

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