GoogleCloudPlatform / cloud-sql-proxy

A utility for connecting securely to your Cloud SQL instances
Apache License 2.0
1.28k stars 349 forks source link

Environment variable names for configuration #2263

Open noonessh opened 4 months ago

noonessh commented 4 months ago

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

enocom commented 4 months ago

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

See https://github.com/GoogleCloudPlatform/cloud-sql-proxy/blob/136595b0dbc996b2ed5703e5c2cc4d9d0b80ed40/cmd/root.go#L223-L247 for the message.

pataquets commented 3 months ago

@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 commented 3 months ago

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

pataquets commented 3 months ago

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 commented 3 months ago

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