@andreafspeziale/os-cli v1.7.0
Installation
The Official opensearch-cli is also available
npm
npm install -g @andreafspeziale/os-cli
yarn
yarn global add @andreafspeziale/os-cli
pnpm
pnpm add -g @andreafspeziale/os-cli
docker
docker pull andreafspeziale/os-cli
docker run --rm --env-file .env andreafspeziale/os-cli
If using a local (docker) OpenSearch image like the one included in the
docker-compose
file be sure to set correctly thenetwork
option andOS_HOST
env variable (OS_HOST=http://opensearch:9200) in the above command (docker run --rm --env-file .env --network os-cli_default andreafspeziale/os-cli
)
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.git
cd os-cli
docker compose up -d
export OS_CONNECTION_METHOD=local
npx @andreafspeziale/os-cli i l
oros-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.json
oros-cli i cr -i books -f ./recipes/create-index.json
npx @andreafspeziale/os-cli d cr -i books -f ./recipes/create-documents.json
oros-cli d cr -i books -f ./recipes/create-documents.json
npx @andreafspeziale/os-cli d q -i books -f ./recipes/query.json
oros-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 | proxy | http://localhost:(9200 | 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 | 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 | info | 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-cli
cp ./env/.env.development ./env
docker compose up -d
pnpm install
I personally prefer build in a terminal window and run the compiled version in a separate one like so:
pnpm build --watch
pnpm start:prod
ornode dist/os-cli.js
Stay in touch
- Author - Andrea Francesco Speziale
- Website - https://nestjs.com
- Twitter - @nestframework
License
os-cli MIT licensed.
13 days ago
5 months ago
5 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago