Skip to content

GCS Connection Testing

In order to test connection to a Google Storage (GCS) bucket you need to execute connect test gcs followed by one mandatory parameter:

  • --bucket then the GCS bucket name

Depending on the type of authentication you need to either use --auth-json for key based authentication or use the service account assigned to the instance (if the server is running on GCP).

To use JSON key for the authentication you need to provide:

  • --auth-json then the path to the file containing the auth JSON

For example:

Terminal window
$ connect test gcs --auth-json /path/to/key-file.json --bucket my-gcs-bucket
2025/05/22 08:42:12 INFO Testing connection to gcs://my-gcs-bucket/
2025/05/22 08:42:13 INFO Connection successful

To authenticate with Application Default Credentials (ADC) you need to set GOOGLE_APPLICATION_CREDENTIALS environment variable that points to the key file.

Terminal window
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key-file.json"

Then you can omit providing the key file as it will be obtained from the environment variable. For example:

Terminal window
$ connect test gcs --bucket my-gcs-bucket
2025/05/22 08:44:11 INFO Testing connection to gcs://my-gcs-bucket/
2025/05/22 08:44:12 INFO Connection successful

For user credentials, ADC can be set by running Following

Terminal window
$ gcloud auth application-default login

Once authenticated you can connect without specifying the JSON key.

Terminal window
$ connect test gcs --bucket my-gcs-bucket
2025/05/22 08:45:00 INFO Testing connection to gcs://my-gcs-bucket/
2025/05/22 08:45:01 INFO Connection successful
Terminal window
Usage:
connect test gcs [command] [flags]
Flags:
--auth-json string GCS authentication json file
--bucket string GCS bucket
Global Flags:
--godebug Turns on debug mode
--help Prints help for the command
--log-format string Log output format: text|json (default "text")
--no-color Do not use colors in logs
--quiet Makes no output

Please check here for information on the possible errors.