My IBM Log in

January 28, 2021 By Henrik Loeser 3 min read

A closer look at some useful IBM Cloud CLI environmental variables.

In some of my past IBM Cloud blogs, I showed you how to interact with IBM Cloud services from the command line. Today, I want to share some tips and tricks for the IBM Cloud CLI (command line interface), the ibmcloud command. Many of you work with that command, but have you ever looked into its help option and its environment variables? Here is a quick look at those variables and how to put them to good use:

To colorize or not to colorize the IBM Cloud CLI output.

To colorize or not to colorize the IBM Cloud CLI output.

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 for readability):

$ 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. In the following, I am going to briefly describe each of them and how I utilize them in my work. In your shell, you set those environment variables by a VARIABLE_NAME=VALUE pair directly in front of the command, or by using export VARIABLE_NAME=VALUE as a separate command before executing the actual shell command. 

  • IBMCLOUD_COLOR: Setting and unsetting IBMCLOUD_COLOR to true or false allows you to control colorized output. Its usage and impact is shown on the screenshot at the top. The default is colorized CLI output.
  • IBMCLOUD_VERSION_CHECK: This controls the regular versioning check for the CLI tool. Based on my observation the default is true.
  • IBMCLOUD_API_KEY: Something helpful for simplification and testing is to utilize IBMCLOUD_API_KEY. The command ibmcloud login allows you to authenticate via an API key. That key can be specified directly as value or by referencing the name of the file containing the key via @filename. See the screenshot below for an example: 

    Authenticate to IBM Cloud using an API key.

  • IBMCLOUD_TRACE: 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. The following screenshot shows how to enable tracing for just the executed command: 

    Tracing an ibmcloud command.

  • IBMCLOUD_HOME: Last, but not least, IBMCLOUD_HOME is great for testing again. The ibmcloud command reads and writes its session metadata from/to the specified path. 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. This is great for automated, parallel testing or working with different accounts at the same time. Have a different directory for each and you are good to go.

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 would like to use an on-demand CLI environment, I recommend experimenting with the IBM Cloud Shell.

If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn.

Was this article helpful?
YesNo

More from Cloud

Attention new clients: exciting financial incentives for VMware Cloud Foundation on IBM Cloud

4 min read - New client specials: Get up to 50% off when you commit to a 1- or 3-year term contract on new VCF-as-a-Service offerings, plus an additional value of up to USD 200K in credits through 30 June 2025 when you migrate your VMware workloads to IBM Cloud®.1 Low starting prices: On-demand VCF-as-a-Service deployments begin under USD 200 per month.2 The IBM Cloud benefit: See the potential for a 201%3 return on investment (ROI) over 3 years with reduced downtime, cost and…

24 IBM offerings winning TrustRadius 2024 Top Rated Awards

2 min read - TrustRadius is a buyer intelligence platform for business technology. Comprehensive product information, in-depth customer insights and peer conversations enable buyers to make confident decisions. “Earning a Top Rated Award means the vendor has excellent customer satisfaction and proven credibility. It’s based entirely on reviews and customer sentiment,” said Becky Susko, TrustRadius, Marketing Program Manager of Awards. Top Rated Awards have to be earned: Gain 10+ new reviews in the past 12 months Earn a trScore of 7.5 or higher from…

IBM Tech Now: April 8, 2024

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 96 On this episode, we're covering the following topics: IBM Cloud Logs A collaboration with IBM watsonx.ai and Anaconda IBM offerings in the G2 Spring Reports Stay plugged in You can check out the…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters
Overview Annual report Corporate social responsibility Diversity & inclusion Financing Investor Newsroom Security, privacy & trust Senior leadership Careers with IBM Website Blog Publications Automotive Banking Consumer Good Energy Government Healthcare Insurance Life Sciences Manufacturing Retail Telecommunications Travel Our strategic partners Find a partner Become a partner - Partner Plus Partner Plus log in IBM TechXChange Community LinkedIn X Instagram YouTube Subscription Center Participate in user experience research Podcasts United States — English Contact IBM Privacy Terms of use Accessibility