snowflakedb/snowflake-cli

SNOW-1460094: Docs unclear about `--temporary-connection` when using env variables in snow cli

Closed this issue · 3 comments

Description

Description
I'm currently setting up snow-cli as part of a CI/CD pipeline. I wanted to use environment variables to specify the connections details as described here (without a config.toml):
https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/connecting/specify-credentials#label-snowcli-environment-creds

As a precautionary measure, I made sure no config.toml would be present in the system. But no matter what I did, the env-variables would not get picked up.

Solution
In order to make this work, I needed to specify --temporary-connection, otherwise the env variables would get ignored.
I'm not sure, if this is the right way to do it, but it worked in my case.

Improvement (proposal)
It would be great to have this written explicitly in the docs that there is an additional step needed. As it stands now, one has to assume that it "just works" when settings these env variables, which is unfortunately not the case.

Additional feedback
Also, my general assumption was, that these parameters would "merge" and that the env-variables have precedence over what's written in the config.toml. Instead they simply are ignored. Maybe it would be helpful to add a warning, that there are env variables being ignored.

Context

No response

Hi @mydata-ag, the purpose of --temporary-connection flag was to execute command without config.toml file but with connection parameters in command line, so it should be

snow sql -q "select 1" --temporary-connection --account "acc1" --user "user1"

or with env variables

snow sql -q "select 1" --temporary-connection --account $ACCOUNT --user $USER

Could you sent how exactly did you run Snowflake CLI?

export SNOWFLAKE_USER=***
export SNOWFLAKE_PASSWORD=***
export SNOWFLAKE_ACCOUNT=***
export SNOWFLAKE_WAREHOUSE=***
export SNOWFLAKE_SCHEMA=PUBLIC
export SNOWFLAKE_DATABASE=***
export SNOWFLAKE_ROLE=***
export SNOWFLAKE_USE_PROXY=***
export SNOWFLAKE_PROXY_HOST=***
export SNOWFLAKE_PROXY_PORT=***
export SNOWFLAKE_PROXY_USER=***
export SNOWFLAKE_PROXY_PASSWORD=***

poetry run snow streamlit deploy --temporary-connection --replace

Your way is right. We are missing this information in the documentation. Thank you for pointing it out!

Override hierarchy (from least to most):

  • config.toml
  • Generic environment variables
  • Connection-specific environment variables
  • Flags