Logging in with a Compute Resource Token
You can use a trusted profile to set up fine-grained authorization for applications that are running in compute resources. As a result, you aren't required to create service IDs or API keys for the compute resources. The IBM Cloud CLI supports logging in and authenticating to IBM Cloud by using an IBM Cloud Kubernetes Service compute resource. For instructions about logging in as a Virtual Server Instance for VPC compute resource by using the IBM Cloud CLI, see Logging in as a Virtual Server Instance Compute Resource Identity.
For more information about managing trusted profiles and establishing trust with compute resources, see Establishing trust with compute resources.
Using the CLI to log in
To use the IBM Cloud CLI Kubernetes Service compute resource login feature, you must give application pods that run in your IBM Cloud Kubernetes Service cluster access to IBM Cloud services. For more information, see Authorizing pods in your cluster to IBM Cloud services with IAM trusted profiles. For Red Hat OpenShift clusters, see Authorizing pods in your Red Hat OpenShift cluster to IBM Cloud services with IAM trusted profiles.
Using a Compute Resource Token to log in with the CLI
When you use the compute resource token option to log in with a service account-projected token, you specify the compute resource token parameter to enter at login.
You can log in with a compute resource token with the CLI in any of the following ways:
-
Call the Compute Resource token directly:
- Specify the
--cr-tokenoption with theibmcloud logincommand, and provide the content of the compute resource token. - Specify the
--profileoption with theibmcloud logincommand, and provide the ID, name, or CRN of the IAM trusted profile that the cluster is linked to.
ibmcloud login --cr-token <token_string> --profile <profile_id_name_or_crn_string> - Specify the
-
Call the Compute Resource token with the token file:
- Specify the
--cr-tokenoption with theibmcloud logincommand, and provide the file path of a compute resource token file. - Specify the
--profileoption with theibmcloud logincommand, and provide the ID, name, or CRN of the IAM trusted profile that the cluster is linked to.
ibmcloud login --cr-token @token_file_name --profile <profile_id_name_or_crn_string> - Specify the
-
Set the
IBMCLOUD_CR_TOKENenvironment variable.Additionally, you can set the environment variable on your system. For example, set
IBMCLOUD_CR_TOKEN=token_string, wheretoken_stringis the custom value of the compute resource token, orIBMCLOUD_CR_TOKEN=@token_file_name, where@token_file_nameis the file path of a compute resource token file that contains the contents of the token. After the environment variable is set, you can simply specifyibmcloud login --profile <profile_id_name_or_crn_string>from the CLI. -
Set both
IBMCLOUD_CR_TOKENandIBMCLOUD_CR_PROFILEenvironment variables.Additionally, you can set both environment variables on your system. For example,
IBMCLOUD_CR_TOKEN=token_string, wheretoken_stringis the custom value of the compute resource token, andIBMCLOUD_CR_PROFILE=profile_id_name_or_crn_string, whereprofile_id_name_or_crn_stringis the ID, name, or CRN of the IAM trusted profile that the cluster is linked to. After both environment variables are set, you can simply specifyibmcloud loginfrom the CLI.
The resulting login session is valid for 60 minutes.