IBM Cloud CLI options |
IBM Cloud CLI environment variables
When I look up help on the root of the ibmcloud command, the output is something like this (with the list of commands cut away):
$ ibmcloud --help
NAME:
ibmcloud - A command line tool to interact with IBM Cloud
Find more information at: https://ibm.biz/cli-docs
USAGE:
[environment variables] ibmcloud [global options] command [arguments...] [command options]
...
Enter 'ibmcloud help [command]' for more information about a command.
ENVIRONMENT VARIABLES:
IBMCLOUD_COLOR=false Do not colorize output
IBMCLOUD_VERSION_CHECK=false Do not check latest version for update
IBMCLOUD_HTTP_TIMEOUT=5 A time limit for HTTP requests
IBMCLOUD_API_KEY=api_key_value API Key used for login
IBMCLOUD_TRACE=true Print API request diagnostics to stdout
IBMCLOUD_TRACE=path/to/trace.log Append API request diagnostics to a log file
IBMCLOUD_HOME=path/to/dir Path to config directory
GLOBAL OPTIONS:
--version, -v Print the version
--help, -h Show help
At the bottom of the output is a section on environment variables. They allow to customize the way you work with the IBM Cloud CLI or are great for some investigation.
- Setting and unsetting IBMCLOUD_COLOR to true or false allows you to control colorized output. It is shown on the screenshot at the top. The default is colorized CLI output.
- IBMCLOUD_VERSION_CHECK controls the regular versioning check for the CLI tool. Based on my observation the default is true.
- Depending on your network connectivity, you might want to adjust the timeout using IBMCLOUD_HTTP_TIMEOUT.
- A great option for simplification and testing is IBMCLOUD_API_KEY. The command "ibmcloud login" allows to authenticate via an API key. That key can be specified directly or as @filename. See the screenshot below for an example.
- Utilize IBMCLOUD_TRACE to investigate how CLI commands are executed. By default it is off. When enabled, it prints many useful details to the standard output (your terminal) or to the specified file. I often use it to look into how the CLI commands interact with the IBM Cloud platform and service APIs.
- Last but not least, IBMCLOUD_HOME is great for testing again. It let's you set a path for the local account metadata. As I pointed out in this Stack Overflow answer, you could use it to work with multiple accounts or multiple sessions at the same time. Have a different directory for each and you are good to go.
Use the API key for login to IBM Cloud |
Conclusions
By adapting your IBM Cloud CLI environment through environment variables, you can get more out of it. Use the capabilities to simplify API key-based login, to have multiple different CLI sessions in parallel or to investigate code flow.
If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn.