Connect Confluent Cloud CLI to a Cluster

You can connect your Confluent Cloud CLI instance to a Confluent Cloud cluster by following this procedure.

Prerequisite
The Confluent Cloud CLI must be installed.
  1. Log in to your cluster using the ccloud login command with the cluster URL specified.

    ccloud login --url https://confluent.cloud
    
    Enter your Confluent Cloud credentials:
    Email: susan@myemail.com
    Password:
    
  2. Set the Confluent Cloud environment.

    1. Get the environment ID.

      ccloud environment list
      

      Your output should resemble:

           Id    |      Name
      +----------+----------------+
        * a-542  | dev
          a-4985 | prod
          a-2345 | jdoe-gcp-env
          a-9012 | jdoe-aws-env
      
    2. Set the environment using the ID (<env-id>).

      ccloud environment use <env-id>
      

      Your output should resemble:

      Now using a-4985 as the default (active) environment.
      
  3. Set the cluster to use.

    1. Get the cluster ID.

      ccloud kafka cluster list
      

      Your output should resemble:

            Id      |       Name        | Provider |   Region    | Durability | Status
      +-------------+-------------------+----------+-------------+------------+--------+
          ekg-rr8v7 | dev-aws-oregon    | aws      | us-west-2   | LOW        | UP
          ekg-q2j96 | prod              | gcp      | us-central1 | LOW        | UP
      
    2. Set the cluster using the ID (<cluster-id>). This is the cluster where the commands are run.

      ccloud kafka cluster use <cluster-id>
      
  4. Set the API key/secret to use. This is the API key/secret pair that is used to run the commands.

    • If you are using an existing API key/secret, run these commands:

      1. Store the API key/secret locally, with the cluster ID (<cluster-id>), API key (<api-key>), and API secret (<api-secret>) specified.

        ccloud api-key store <api-key> <api-secret> --cluster <cluster-id>
        
      2. Associate the API key/secret with this cluster, the API key (<api-key>) must be specified.

        ccloud api-key use <api-key>
        
    • If you are creating a new API key/secret, run these commands:

      1. Create a new API key/secret and save the output.

        ccloud api-key create
        

        Your output should resemble:

        Save the API key and secret. The key/secret is not retrievable later.
        +---------+------------------------------------------------------------------+
        | API Key | KIELS5LZKXCBOT9L                                                 |
        | Secret  | XVLE434R43R532RFSASDeaatawefafeazzzeeeeeelllll4354t5345452432x   |
        +---------+------------------------------------------------------------------+
        
      2. Associate the API key/secret with this cluster, the API key (<api-key>) must be specified.

        ccloud api-key use <api-key>
        

You can now run Confluent Cloud CLI commands against the specified cluster. For more information, see Confluent Cloud CLI Command Reference.