0

Set the AWS Endpoint Connection state

by
Published Oct 17, 2025

The "status" in the response does not reflect the latest post-update status, but rather the status before the state is transitioned. Can be used by the following roles assigned at the organization, folder or cluster scope: - CLUSTER_ADMIN - CLUSTER_OPERATOR_WRITER

Script cockroachdb Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Cockroachdb = {
3
  token: string;
4
};
5
/**
6
 * Set the AWS Endpoint Connection state
7
 * The "status" in the response does not reflect the latest post-update
8
status, but rather the status before the state is transitioned.
9

10
Can be used by the following roles assigned at the organization, folder or cluster scope:
11
- CLUSTER_ADMIN
12
- CLUSTER_OPERATOR_WRITER
13

14
 */
15
export async function main(
16
  auth: Cockroachdb,
17
  cluster_id: string,
18
  endpoint_id: string,
19
  body: { status: "AVAILABLE" | "REJECTED" },
20
) {
21
  const url = new URL(
22
    `https://cockroachlabs.cloud/api/v1/clusters/${cluster_id}/networking/aws-endpoint-connections/${endpoint_id}`,
23
  );
24

25
  const response = await fetch(url, {
26
    method: "PATCH",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Bearer " + auth.token,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39