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.
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:
- Fine-grained access control is enabled
- Use the
Domain
L2 construct - The master is authenticated with username and password, and the credential is stored in Secret Manager
- Domain access policy is configured to allow access from the master user
{
"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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file opensearch-rest-resources-0.0.12.tar.gz
.
File metadata
- Download URL: opensearch-rest-resources-0.0.12.tar.gz
- Upload date:
- Size: 100.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce5d9f706b42dc8af09b51f1751493fe7ea5ebaeb73f1f5ea4935a604cbb233a |
|
MD5 | cb3e5caaba8f2a53d804f44064454fb4 |
|
BLAKE2b-256 | 23bb9262ac2307b91f8b48a38f3a9ea7757022a88623c0aec51d9d909459511c |
File details
Details for the file opensearch_rest_resources-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: opensearch_rest_resources-0.0.12-py3-none-any.whl
- Upload date:
- Size: 98.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3454786dfb51f851d77bdd072b9e597457b41e66e66a0bf6ea63b6c158f8d0e7 |
|
MD5 | ef5bbec9be36d88b735ba2a0b21218c0 |
|
BLAKE2b-256 | cf05c62aa46f0504f61bbf1e5f4ffa6cedfa705c5dbb926c77ccb2e2a78363d9 |