@andreafspeziale/os-cli v1.9.0
Installation
The Official opensearch-cli is also available
npm
npm install -g @andreafspeziale/os-cliyarn
yarn global add @andreafspeziale/os-clipnpm
pnpm add -g @andreafspeziale/os-clidocker
docker pull andreafspeziale/os-cli
docker run --rm --env-file .env andreafspeziale/os-cliIf using a local (docker) OpenSearch image like the one included in the
docker-composefile be sure to set correctly thenetworkoption andOS_HOSTenv variable (OS_HOST=http://opensearch:9200) in the above command (docker run --rm --env-file .env --network os-cli_default andreafspeziale/os-cli)If using the dockerized CLI and you need to use your json payloads as inputs you'll need to mount the folder into the CLI execution context (e.g
docker run --rm --env-file .env -v ./recipes:/opt/os-cli/recipes --network os-cli_default andreafspeziale/os-cli d q -i books -f recipes/query.json)
How to use?

Quickstart
To taste the CLI very quickly using npx or after installing it you can spawn OpenSearch locally by using the docker-compose file included in the repository:
git clone git@github.com:andreafspeziale/os-cli.gitcd os-clidocker compose up -dexport OS_CONNECTION_METHOD=localnpx @andreafspeziale/os-cli i loros-cli i l
Like the docker-compose file there are also some recipes included in the repository:
npx @andreafspeziale/os-cli i cr -i books -f ./recipes/create-index.jsonoros-cli i cr -i books -f ./recipes/create-index.jsonnpx @andreafspeziale/os-cli d cr -i books -f ./recipes/create-documents.jsonoros-cli d cr -i books -f ./recipes/create-documents.jsonnpx @andreafspeziale/os-cli d q -i books -f ./recipes/query.jsonoros-cli d q -i books -f ./recipes/query.json
Configuration
For proxy mode check aws-sigv4-proxy
The CLI leverages environment variables in order to set connection and logging options just once.
| Name | Required | Default | Description | Values |
|---|---|---|---|---|
| OS_HOST | when OS_CONNECTION_METHOD is NOT local or proxy | http://localhost:(9200 or 8080) | OpenSearch connection host | - |
| OS_CONNECTION_METHOD | Yes | - | How you want to connect to OpenSearch | local, proxy, serviceAccount, credentials |
| AWS_REGION | only when OS_CONNECTION_METHOD is NOT local or proxy | - | OpenSearch AWS connection region | - |
| AWS_ROLE_ARN | only when OS_CONNECTION_METHOD is serviceAccount | - | AWS role ARN for assume role connection | - |
| AWS_WEB_IDENTITY_TOKEN_FILE | only when OS_CONNECTION_METHOD is serviceAccount | - | AWS web identity token file | - |
| AWS_ACCESS_KEY_ID | only when OS_CONNECTION_METHOD is credentials | - | AWS access key id for canonical connection | - |
| AWS_SECRET_ACCESS_KEY | only when OS_CONNECTION_METHOD is credentials | - | AWS secret access key for canonical connection | - |
| LOGGER_LEVEL | No | debug | Which logs will be displayed | silent, error, warn, info, http, verbose, debug |
| LOGGER_PRETTY | No | true | Boolean to enable/disable logs formatting | true, false |
| LOGGER_REDACT | No | '' | Removed specified words from logs | - |
For a docker local OpenSearch instance all you need to do is:
export OS_CONNECTION_METHOD=local
Instead for a canonical AWS connection method a receipt along with your values would be:
export OS_HOST=
export OS_CONNECTION_METHOD=credentials
export AWS_REGION=
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=Development
After cloning the repository:
cd os-clicp ./env/.env.development ./envdocker compose up -dpnpm install
I personally prefer build in a terminal window and run the compiled version in a separate one like so:
pnpm build --watchpnpm start:prodornode dist/os-cli.js
Stay in touch
- Author - Andrea Francesco Speziale
- Website - https://nestjs.com
- Twitter - @nestframework
License
os-cli MIT licensed.
8 months ago
8 months ago
8 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago