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
    
    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. Create the API key/secret with the resource ID (<resource-id>) specified and save the output. You can find the Kafka resource ID by using the ccloud kafka cluster list command. You can find the Schema Registry resource ID by using the ccloud schema-registry cluster describe command.

    ccloud api-key create --resource <resource-id>
    

    Your output should resemble:

    Save the API key and secret. The key/secret is not retrievable later.
    +---------+------------------------------------------------------------------+
    | API Key | KIELS5LZKXCBOT9L                                                 |
    | Secret  | XVLE434R43R532RFSASDeaatawefafeazzzeeeeeelllll4354t5345452432x   |
    +---------+------------------------------------------------------------------+
    

    Tip

    To use an existing API key/secret, run this command with the resource ID (<resource-id>), API key (<api-key>), and API secret (<api-secret>) specified. This command registers an API key/secret created by another process and stores it locally.

    ccloud api-key store <api-key> <api-secret> --resource <resource-id>
    
  5. Associate the Kafka API key/secret with this cluster, the API key (<api-key>) must be specified. This step is not necessary for Schema Registry resources.

    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.