Skip to content

Commit

Permalink
Update OpenSearch endpoint ENV variable
Browse files Browse the repository at this point in the history
Why these changes are being introduced:
The ENV variable name for the OpenSearch endpoint has been changed in
Terraform to match the name formatting for other TIMDEX ENV variables,
so the code here needs to change as well.

How this addresses that need:
* Update ENV variable name from OPENSEARCH_ENDPOINT to
  TIMDEX_OPENSEARCH_ENDPOINT across the repo, including in the README.
  • Loading branch information
hakbailey committed Oct 18, 2022
1 parent 52bda73 commit 6293891
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ TIMDEX! Index Manager (TIM) is a Python cli application for managing TIMDEX inde
## Optional ENV

- `AWS_REGION` = Only needed if AWS region changes from the default of us-east-1.
- `OPENSEARCH_ENDPOINT` = If using a local Docker OpenSearch instance, this isn't needed. Otherwise set to OpenSearch instance endpoint _without_ the http scheme, e.g. `search-timdex-env-1234567890.us-east-1.es.amazonaws.com`. Can also be passed directly to the CLI via the `--url` option.
- `OPENSEARCH_REQUEST_TIMEOUT` = Only used for OpenSearch requests that tend to take longer than the default timeout of 10 seconds, such as bulk or index refresh requests. Defaults to 30 seconds if not set.
- `SENTRY_DSN` = If set to a valid Sentry DSN, enables Sentry exception monitoring. This is not needed for local development.
- `STATUS_UPDATE_INTERVAL` = The ingest process logs the # of records indexed every nth record (1000 by default). Set this env variable to any integer to change the frequency of logging status updates. Can be useful for development/debugging.
- `TIMDEX_OPENSEARCH_ENDPOINT` = If using a local Docker OpenSearch instance, this isn't needed. Otherwise set to OpenSearch instance endpoint _without_ the http scheme, e.g. `search-timdex-env-1234567890.us-east-1.es.amazonaws.com`. Can also be passed directly to the CLI via the `--url` option.

## Development

Expand All @@ -37,5 +37,5 @@ To confirm the instance is up, run `pipenv run tim -u localhost ping`.
### OpenSearch on AWS

1. Ensure that you have the correct AWS credentials set for the Dev1 (or desired) account.
2. Set the `OPENSEARCH_ENDPOINT` variable in your .env to match the Dev1 (or desired) TIMDEX OpenSearch endpoint (note: do not include the http scheme prefix).
2. Set the `TIMDEX_OPENSEARCH_ENDPOINT` variable in your .env to match the Dev1 (or desired) TIMDEX OpenSearch endpoint (note: do not include the http scheme prefix).
3. Run `pipenv run tim ping` to confirm the client is connected to the expected TIMDEX OpenSearch instance.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_env():
"AWS_ACCESS_KEY_ID": "test",
"AWS_SECRET_ACCESS_KEY": "test",
"AWS_SESSION_TOKEN": "test",
"OPENSEARCH_ENDPOINT": "localhost",
"TIMDEX_OPENSEARCH_ENDPOINT": "localhost",
"SENTRY_DSN": None,
"WORKSPACE": "test",
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def escape_ansi(line):
def test_main_group_no_options_configures_correctly_and_invokes_result_callback(
caplog, monkeypatch, runner
):
monkeypatch.delenv("OPENSEARCH_ENDPOINT", raising=False)
monkeypatch.delenv("TIMDEX_OPENSEARCH_ENDPOINT", raising=False)
result = runner.invoke(main, ["ping"])
assert result.exit_code == 0
assert "Logger 'root' configured with level=INFO" in caplog.text
Expand All @@ -29,7 +29,7 @@ def test_main_group_no_options_configures_correctly_and_invokes_result_callback(
def test_main_group_all_options_configures_correctly_and_invokes_result_callback(
caplog, monkeypatch, runner
):
monkeypatch.delenv("OPENSEARCH_ENDPOINT", raising=False)
monkeypatch.delenv("TIMDEX_OPENSEARCH_ENDPOINT", raising=False)
result = runner.invoke(main, ["--verbose", "--url", "localhost", "ping"])
assert result.exit_code == 0
assert "Logger 'root' configured with level=DEBUG" in caplog.text
Expand Down
6 changes: 3 additions & 3 deletions tim/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
@click.option(
"-u",
"--url",
envvar="OPENSEARCH_ENDPOINT",
envvar="TIMDEX_OPENSEARCH_ENDPOINT",
default="localhost",
help="The OpenSearch instance endpoint minus the http scheme, e.g. "
"'search-timdex-env-1234567890.us-east-1.es.amazonaws.com'. If not provided, will "
"attempt to get from the OPENSEARCH_ENDPOINT environment variable. Defaults to "
"'localhost'.",
"attempt to get from the TIMDEX_OPENSEARCH_ENDPOINT environment variable. Defaults "
"to 'localhost'.",
)
@click.option(
"-v", "--verbose", is_flag=True, help="Pass to log at debug level instead of info"
Expand Down

0 comments on commit 6293891

Please sign in to comment.