Skip to content

Add Elastic Cloud Connect API support (elastic cloud connected) #818

Closed as duplicate

Description

@consulthys

Summary

Add the Elastic Cloud Connect API to the Elastic CLI so users can accept Cloud Connect terms, list/create/update/disconnect Cloud Connected clusters, and rotate Cloud Connect API keys from elastic cloud.

This is not AutoOps insights (#393). Insights consume events for a resource that is already monitored. Cloud Connect is how a self-managed, ECE, or ECK cluster is registered with Elastic Cloud so those services (AutoOps, and later others) can run.

elastic kb fleet-cloud-connectors is a different API (Kibana Fleet). Do not reuse that group.

Spec (source of truth)

Elastic Cloud Connected API, OpenAPI 3.0.1 (info.version 0.1.0).

Paths are under /api/v1/cloud-connected/…. Cluster IDs are 32 hex (^[a-z0-9]{32}$). Organization IDs match ^[a-z0-9]{1,32}$ — discover with existing elastic cloud orgs list-organizations; do not invent an org-wide _all.

Already shipped — do not reimplement

Need Existing command
Discover organization_id elastic cloud orgs list-organizations
Org-scoped Cloud Connect registration key (cloud-connected-admin / cloud_connected_resource) elastic cloud auth create-api-key / get-api-keys
Elasticsearch AutoOps key on the self-managed cluster elastic es security create-api-key / put-role

The org registration key body (already accepted by POST /api/v1/users/auth/keys) looks like:

{
  "description": "CCM Registration Key",
  "role_assignments": {
    "cloud_connected_resource": [
      {
        "organization_id": "<org_id>",
        "role_id": "cloud-connected-admin",
        "all": true
      }
    ]
  }
}

That secret is what agents send as ELASTIC_CLOUD_CONNECTED_MODE_API_KEY. Elastic Agent 9.4.9+ / 9.5.6+ no longer uses AUTOOPS_TOKEN or AUTOOPS_TEMP_RESOURCE_ID. Do not add CLI flags for those.

Endpoints to cover

Organizations

HTTP Purpose
GET /api/v1/cloud-connected/organizations/{organization_id}/terms-and-conditions Whether T&C are accepted (accepted.accepted_at / accepted_by only when accepted)
POST /api/v1/cloud-connected/organizations/{organization_id}/terms-and-conditions/_accept Accept T&C (first-time connect)
GET /api/v1/cloud-connected/organizations/{organization_id}/subscription Subscription state: trial | active | inactive

Clusters

HTTP Purpose
GET /api/v1/cloud-connected/clusters List. Response is { items: Cluster[] }. Schema says “paginated” but there is no cursor / next field — do not invent pagination flags.
POST /api/v1/cloud-connected/clusters?create_api_key= Create / onboard. 200 if the cluster already existed, 201 if created. Query create_api_key=true returns a cloud-connected-admin key scoped to that cluster; revoked on disconnect. Required body: self_managed_cluster.{id,name,version} and license.{type,uid}. Optional name (max 255).
GET /api/v1/cloud-connected/clusters/{id} Get one. Capture ETag for PATCH / DELETE / rotate.
PATCH /api/v1/cloud-connected/clusters/{id} Partial update (name, self_managed_cluster, license, services.{auto_ops,eis}.enabled). Optional If-Match.
DELETE /api/v1/cloud-connected/clusters/{id} Disconnect. Optional If-Match. Response is “disconnection scheduled”. Product behavior: this permanently deletes AutoOps metrics for that cluster — CLI should confirm on TTY and print that warning.

License type enum: trial | basic | standard | dev | silver | gold | platinum | enterprise.

Cluster always includes id, name, metadata.{created_at,created_by,organization_id}, self_managed_cluster, license, services.{auto_ops,eis}. Surface those. Do not invent other service keys.

API key rotation

HTTP Purpose
POST /api/v1/cloud-connected/clusters/{id}/apikey/_rotate Rotate the cluster management key. Returns { key }. Previous key revoked after 7 days or via _revoke-pending.
POST /api/v1/cloud-connected/clusters/{id}/apikey/_revoke-pending Revoke pending rotated cluster keys immediately.
POST /api/v1/cloud-connected/clusters/{id}/apikey/{service}/_rotate Rotate a service key. Path service enum is currently eis only (OpenAPI ServiceName).
POST /api/v1/cloud-connected/clusters/{id}/apikey/{service}/_revoke-pending Revoke pending rotated service keys immediately.

Print returned keys once. Do not log them. Optional If-Match on all four.

Errors

Bodies are { errors: [ { message, code } ] } (MultiErrorResponse). Statuses used by the spec: 400, 401, 403, 404, 409, 412, 422. Map 412 to a clear “ETag mismatch — GET again” message.

UX / command structure

Promote a connected group under elastic cloud (same idea as auth / orgs: not hosted-vs-serverless). Suggested contract:

elastic cloud connected organizations get-terms --organization-id <id>
elastic cloud connected organizations accept-terms --organization-id <id>
elastic cloud connected organizations get-subscription --organization-id <id>

elastic cloud connected clusters list
elastic cloud connected clusters create [--create-api-key] [--input-file <json>]
elastic cloud connected clusters get --id <id>
elastic cloud connected clusters update --id <id> [--if-match <etag>] [--input-file <json>]
elastic cloud connected clusters delete --id <id> [--if-match <etag>]

elastic cloud connected clusters rotate-api-key --id <id> [--if-match <etag>]
elastic cloud connected clusters revoke-pending-api-keys --id <id> [--if-match <etag>]
elastic cloud connected clusters rotate-service-api-key --id <id> --service eis [--if-match <etag>]
elastic cloud connected clusters revoke-pending-service-api-keys --id <id> --service eis [--if-match <etag>]

Codegen from the OpenAPI is fine; rename via the existing Cloud namespace maps so the user-facing tree matches the above. If the CLI can default --organization-id from the Cloud context when the user belongs to a single org, do that — still allow an explicit flag.

Flags should follow the request 1:1 (--create-api-key, --if-match, --input-file for create/update bodies).

Out of scope

  • Agent install (Linux script, Docker, Helm, Kubernetes, ECK)
  • Elasticsearch API keys / roles (already elastic es security)
  • Org Cloud API keys (already elastic cloud auth)
  • Insights search/get (#393 — elastic cloud monitoring)
  • Kibana Fleet cloud connectors (elastic kb fleet-cloud-connectors)
  • FedRAMP Cloud offerings (Cloud Connect is not available there)

Why this is needed

Without these commands, connecting a self-managed cluster requires raw HTTP against /api/v1/cloud-connected/…. Terms acceptance, cluster list/disconnect, and key rotation have no CLI equivalent today. Agent install and ES/Cloud key minting already exist elsewhere; this fills the Cloud Connect control-plane gap.

cc @JoshMock

Activity

  1. consulthys commented on Nov 13, 2026

    @consulthys
    Author

    Duplicate of #819, can be deleted, opened twice by mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions