Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions dashboard/e2e/integrations-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,32 @@ test("an AWS role without the permissions offers the one-click stack", async ({
await expect(aws.getByRole("switch", { name: "Let agents read Airflow" })).toBeDisabled();
});

test("a self-hosted install's own account never asks for a stack in AWS: the version update brings the permissions", async ({ page }) => {
const list = items().map((i) =>
i.id === `aws-${ACCOUNT}`
? {
...i,
detail: awsDetail({
missing: [],
update_url: null,
install_account: true,
permissions: { status: "update_needed", missing_count: 12 },
}),
}
: i,
);
await mockApi(page, { items: list });
await page.goto("/settings/integrations");
const aws = row(page, `aws-${ACCOUNT}`);
await control(page, `aws-${ACCOUNT}`, `AWS account ${ACCOUNT}`).click();
const panel = aws.getByTestId(`aws-panel-${ACCOUNT}`);
await expect(panel.getByText("These read-only permissions come with the next version update")).toBeVisible();
await expect(panel.getByRole("link", { name: "Open Version and updates" })).toHaveAttribute("href", /\/settings\/system\/?#version$/);
await expect(panel.getByText("the install's own AWS account", { exact: false })).toBeVisible();
await expect(aws.getByRole("link", { name: "Update in AWS" })).toHaveCount(0);
await expect(panel.getByText("CoderHelmLogReader")).toHaveCount(0);
});

test("adding credentials to a switched-on server makes it connected", async ({ page }) => {
const db = await mockApi(page);
await page.goto("/settings/integrations");
Expand Down
13 changes: 11 additions & 2 deletions dashboard/src/components/aws-permissions.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use client";

import Link from "next/link";
import { useCallback, useEffect, useRef, useState } from "react";
import { api, type AwsConnection, type AwsPermissions } from "@/lib/api";
import { timeAgo } from "@/lib/data-sources";
import { Callout } from "./callout";
import { CheckIcon, ExternalLinkIcon, WarningIcon, AlertCircleIcon } from "./icons";
import { buttonClass, primaryButton, secondaryButton } from "./ui";
import { buttonClass, linkButton, primaryButton, secondaryButton } from "./ui";
import { Code } from "./settings/code";

// Whether each connected AWS account's read-only role has every permission
Expand Down Expand Up @@ -270,8 +271,16 @@ export function PermissionsPanel({ account, perms, canEdit }: { account: string;

{v.problem && (
<div className="sm:pl-8">
<Callout variant="error" title={v.problem.message}>
{/* The install's own account: its version update brings these, so nothing is wrong in AWS. */}
<Callout variant={v.install_account ? "neutral" : "error"} title={v.problem.message}>
<p>{v.problem.fix}</p>
{v.install_account && (
<p className="mt-2">
<Link href="/settings/system#version" className={linkButton}>
Open Version and updates
</Link>
</p>
)}
</Callout>
</div>
)}
Expand Down
19 changes: 16 additions & 3 deletions dashboard/src/components/connections.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import Link from "next/link";
import { useState, type ReactNode } from "react";
import { api, type AwsAccountAbilities, type AwsAbilityReply, type Connector, type ConnectorId, type KeyConnectorKind } from "@/lib/api";
import { errorMessage, timeAgo } from "@/lib/data-sources";
Expand Down Expand Up @@ -332,8 +333,10 @@ export function AwsAbilitiesPanel({
return (
<div className="mt-4 flex flex-col gap-4 border-t border-zinc-800 pt-4" data-testid={`aws-panel-${a.account}`}>
<p className="text-sm text-zinc-400">
Coderhelm checks what the CoderHelmLogReader role can do (one read of metrics, one list of Airflow environments) and turns each
ability on when the role allows it. {a.checked_at ? `Last checked ${timeAgo(a.checked_at)}.` : "Not checked yet."}
{a.install_account
? "This is the install's own AWS account: Coderhelm reads it with the install's own role, and each version update brings that role's read-only permissions. Coderhelm checks what it can do (one read of metrics, one list of Airflow environments) and turns each ability on when it can."
: "Coderhelm checks what the CoderHelmLogReader role can do (one read of metrics, one list of Airflow environments) and turns each ability on when the role allows it."}{" "}
{a.checked_at ? `Last checked ${timeAgo(a.checked_at)}.` : "Not checked yet."}
</p>
{a.check_error && (
<Callout variant="error" title="Coderhelm couldn't take on the role" live={false}>
Expand Down Expand Up @@ -385,7 +388,17 @@ export function AwsAbilitiesPanel({
</fieldset>
)}
</div>
{(missing.length > 0 || a.permissions?.status === "update_needed") && a.update_url && (
{a.install_account && (missing.length > 0 || a.permissions?.status === "update_needed") && (
<Callout variant="neutral" title="These read-only permissions come with the next version update" live={false}>
<p>Nothing is needed in AWS. Update Coderhelm and they are on the install&apos;s own role.</p>
<p className="mt-2">
<Link href="/settings/system#version" className={linkButton}>
Open Version and updates
</Link>
</p>
</Callout>
)}
{!a.install_account && (missing.length > 0 || a.permissions?.status === "update_needed") && a.update_url && (
<Callout
variant="warning"
title={
Expand Down
4 changes: 4 additions & 0 deletions dashboard/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3869,6 +3869,8 @@ export interface AwsAccountAbilities {
missing?: string[];
update_url?: string | null;
stack_name?: string;
/** The self-hosted install's own account: read with the install's own role, which version updates keep current. */
install_account?: boolean;
/** The last live check of this release's permissions. */
permissions?: AwsPermissions | null;
}
Expand Down Expand Up @@ -3898,6 +3900,8 @@ export interface AwsPermissions {
missing_abilities: string[];
abilities: AwsPermissionGroup[];
update: { url: string; stack_name: string; template_url: string; sign_in_account: string; stacks_url: string } | null;
/** The self-hosted install's own account: its read-only permissions come with version updates, never from a stack in AWS. */
install_account?: boolean;
problem: { code: string; message: string; fix: string } | null;
}

Expand Down
Loading