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.13.tar.gz (1.1 MB 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.13-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file opensearch_rest_resources-0.0.13.tar.gz.

File metadata

File hashes

Hashes for opensearch_rest_resources-0.0.13.tar.gz
Algorithm Hash digest
SHA256 bb6d000c2f5a0ef4cc04a725855d51d2942bf1386c3016c998cb06ea691c2a6f
MD5 a0eb7cf133eaff09efda765d31640f4b
BLAKE2b-256 b561a13e869a12b21a5b671ac49c8c9d1f22cf446592bfd2db6176f0a00a353e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opensearch_rest_resources-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 dd4e6519f63532019042cd0a38e433265ffb129a667e59703a8776fa2e3fb1a2
MD5 c4e4fa4b37b940243f53643691928435
BLAKE2b-256 1e20bf6246273ad4d508d620a7274c7ba9c3a4c926d531a65717eccf5af63ff0

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