1.7.0 • Published 13 days ago

@andreafspeziale/os-cli v1.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
13 days ago

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 the network option and OS_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?

npm.io

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 or os-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 or os-cli i cr -i books -f ./recipes/create-index.json
  • npx @andreafspeziale/os-cli d cr -i books -f ./recipes/create-documents.json or os-cli d cr -i books -f ./recipes/create-documents.json
  • npx @andreafspeziale/os-cli d q -i books -f ./recipes/query.json or os-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.

NameRequiredDefaultDescriptionValues
OS_HOSTwhen OS_CONNECTION_METHOD is NOT localproxyhttp://localhost:(9200 | 8080)OpenSearch connection host-
OS_CONNECTION_METHODYes-How you want to connect to OpenSearchlocal, proxy, serviceAccount, credentials
AWS_REGIONonly when OS_CONNECTION_METHOD is NOT localproxy-OpenSearch AWS connection region-
AWS_ROLE_ARNonly when OS_CONNECTION_METHOD is serviceAccount-AWS role ARN for assume role connection-
AWS_WEB_IDENTITY_TOKEN_FILEonly when OS_CONNECTION_METHOD is serviceAccount-AWS web identity token file-
AWS_ACCESS_KEY_IDonly when OS_CONNECTION_METHOD is credentials-AWS access key id for canonical connection-
AWS_SECRET_ACCESS_KEYonly when OS_CONNECTION_METHOD is credentials-AWS secret access key for canonical connection-
LOGGER_LEVELNoinfoWhich logs will be displayedsilent, error, warn, info, http, verbose, debug
LOGGER_PRETTYNotrueBoolean to enable/disable logs formattingtrue, false
LOGGER_REDACTNo''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 or node dist/os-cli.js

Stay in touch

License

os-cli MIT licensed.

1.7.0

13 days ago

1.6.1

5 months ago

1.6.0

5 months ago

1.5.0

7 months ago

1.4.1

7 months ago

1.4.0

7 months ago

1.3.0

7 months ago

1.2.0

9 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.0

10 months ago