Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variable names for configuration #2263

Open
noonessh opened this issue Jul 9, 2024 · 5 comments · May be fixed by #2264
Open

Environment variable names for configuration #2263

noonessh opened this issue Jul 9, 2024 · 5 comments · May be fixed by #2264
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: cleanup An internal cleanup or hygiene concern. type: docs Improvement to the documentation for an API.

Comments

@noonessh
Copy link

noonessh commented Jul 9, 2024

Description

Documentation mentions:
The Cloud SQL Auth Proxy has support for:
Configuration with environment variables

However I can't seem to find any details on what exactly the names of environment variables should be?

Potential Solution

No response

Additional Details

No response

@noonessh noonessh added the type: docs Improvement to the documentation for an API. label Jul 9, 2024
@enocom
Copy link
Member

enocom commented Jul 10, 2024

If you run ./cloud-sql-proxy --help, there's a section in the message that explains this.

See

cloud-sql-proxy/cmd/root.go

Lines 223 to 247 in 136595b

Configuration using environment variables
Instead of using CLI flags, the Proxy may be configured using environment
variables. Each environment variable uses "CSQL_PROXY" as a prefix and is
the uppercase version of the flag using underscores as word delimiters. For
example, the --auto-iam-authn flag may be set with the environment variable
CSQL_PROXY_AUTO_IAM_AUTHN. An invocation of the Proxy using environment
variables would look like the following:
CSQL_PROXY_AUTO_IAM_AUTHN=true \
./cloud-sql-proxy my-project:us-central1:my-db-server
In addition to CLI flags, instance connection names may also be specified
with environment variables. If invoking the Proxy with only one instance
connection name, use CSQL_PROXY_INSTANCE_CONNECTION_NAME. For example:
CSQL_PROXY_INSTANCE_CONNECTION_NAME=my-project:us-central1:my-db-server \
./cloud-sql-proxy
If multiple instance connection names are used, add the index of the
instance connection name as a suffix. For example:
CSQL_PROXY_INSTANCE_CONNECTION_NAME_0=my-project:us-central1:my-db-server \
CSQL_PROXY_INSTANCE_CONNECTION_NAME_1=my-other-project:us-central1:my-other-server \
./cloud-sql-proxy
for the message.

@jackwotherspoon jackwotherspoon added the priority: p3 Desirable enhancement or fix. May not be included in next release. label Jul 22, 2024
@pataquets
Copy link

@enocom As far as I could find in the docs, there is no available env var for passing auth tokens when using the --auto-iam-authn switch (if it's possible, but missing in the docs, I'll be happy to send a PR).
This would be super useful, specially for Docker scenarios. It could even automatically assume --auto-iam-auth switch if present for extra convenience.

Would this be an acceptable PR to merge? (I can track this by filing a separate issue, if desired)

@enocom
Copy link
Member

enocom commented Aug 7, 2024

Do you mean CSQL_PROXY_AUTO_IAM_AUTHN? That is supported. Otherwise, there's not a way to manually provide OAuth2 tokens.

@enocom enocom added the type: cleanup An internal cleanup or hygiene concern. label Aug 12, 2024
@pataquets
Copy link

pataquets commented Aug 14, 2024

No, not that one, which just maps to --auto-iam-authn.
I had to dig a bit in the repo to confirm that the env var mapped to that switch, as it's not in the docs (fixed by #2264).
What I'd like to pass as env vars are values for --login-token and --token switches, as they're needed when using --auto-iam-authn.

@enocom
Copy link
Member

enocom commented Aug 15, 2024

Does CSQL_PROXY_LOGIN_TOKEN and CSQL_PROXY_TOKEN not work? We have tests to ensure that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: cleanup An internal cleanup or hygiene concern. type: docs Improvement to the documentation for an API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants