LinuxCommandLibrary

ibmcloud-target

Set IBM Cloud target context

TLDR

View the current target account and region

$ ibmcloud target
copy

Set the target account
$ ibmcloud target -c [account_id]
copy

Switch to a specific region
$ ibmcloud target -r [region_name]
copy

Set the target resource group
$ ibmcloud target -g [resource_group_name]
copy

Clear the targeted region
$ ibmcloud target --unset-region
copy

Clear the targeted resource group
$ ibmcloud target --unset-resource-group
copy

SYNOPSIS

ibmcloud target [OPTIONS]
ibmcloud target [-s | --show]
ibmcloud target [-r REGION_NAME | --region REGION_NAME]
ibmcloud target [-g RESOURCE_GROUP_NAME | --resource-group RESOURCE_GROUP_NAME]
ibmcloud target [-e API_ENDPOINT | --endpoint API_ENDPOINT]

PARAMETERS

-s, --show
    Displays the current IBM Cloud API endpoint, region, and resource group settings.

-r REGION_NAME, --region REGION_NAME
    Sets the target IBM Cloud region where commands will be executed. Example: `us-south`, `eu-de`.

-g RESOURCE_GROUP_NAME, --resource-group RESOURCE_GROUP_NAME
    Sets the target resource group. All subsequent commands will operate within this specified resource group.

-e API_ENDPOINT, --endpoint API_ENDPOINT
    Sets the IBM Cloud API endpoint URL. This is rarely changed unless using a private endpoint or a different cloud environment.

--help
    Displays help information for the `ibmcloud target` command.

DESCRIPTION

The ibmcloud target command is a crucial part of the IBM Cloud Command Line Interface (CLI). It allows users to manage their target settings for interacting with the IBM Cloud platform. Specifically, it enables you to view your current target settings, including the IBM Cloud API endpoint, the currently selected region, and the active resource group. More importantly, it provides the functionality to set these target parameters. Targeting the correct region and resource group ensures that subsequent ibmcloud commands operate on the intended resources within a specific geographical location and organizational container. For instance, you might use it to switch between different development and production environments, or to manage resources in different regions like `us-south` or `eu-de`. This command is essential for consistent and accurate resource management when working with multiple projects or across various cloud locations. It helps avoid accidental operations on the wrong resources by explicitly defining the operational scope for the CLI session.

CAVEATS

Changing the target settings (region, resource group, API endpoint) will affect all subsequent IBM Cloud CLI commands in the current shell session. Always verify your target settings with `ibmcloud target -s` before performing critical operations.
Ensure you are logged in to IBM Cloud (`ibmcloud login`) before attempting to set or view targets.
Resource groups and regions must exist and be accessible to your account, otherwise, the command will fail.

<B>USAGE EXAMPLES</B>

To show current target settings:
`ibmcloud target -s`

To set the target region to `us-south`:
`ibmcloud target -r us-south`

To set the target resource group to `Default`:
`ibmcloud target -g Default`

<B>DEFAULT BEHAVIOR</B>

When `ibmcloud target` is run without any options, it defaults to showing the current target settings, similar to using `ibmcloud target -s`.

HISTORY

The `ibmcloud target` command is a fundamental component of the IBM Cloud CLI, tracing its lineage back to the `Bluemix CLI`. As IBM Cloud evolved, introducing concepts like resource groups and a unified API endpoint, the `target` command adapted to provide a consistent way for users to define their operational context. Its core functionality of setting API, region, and resource group has remained central to managing resources efficiently across different environments and locations within the IBM Cloud ecosystem.

SEE ALSO

ibmcloud login(1), ibmcloud regions(1), ibmcloud resource groups(1)

Copied to clipboard