fix(aws): removal deletes the secret at once and words the access point honestly

Removing a project's AWS resources now deletes its secret with
ForceDeleteWithoutRecovery (R10) so the next start can create it again,
and the EFS option is renamed: it removes the access point, while the
files stay on the user's own file system until offboarding (R9).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-11-15 12:10:52 -08:00
1 parent 55ec7e33fe
commit 3f986368aa
11 files changed
+62 -38

No files matched your search

+11 -6
View File
@@ -2360,12 +2360,17 @@ mod environment {
// reported together), so check them all before the result.
let removed = host.remove_aws_resources(&current(&store), &settings, true).await;
eprintln!("RESULT remove_aws_resources: {:?}", removed.as_ref().map_err(|e| e.chars().take(400).collect::<String>()));
let sm = ok(
"describe the project secret",
t.e.secrets.describe_secret().secret_id(project_secret_name(&name, &okey, &id)).send().await,
);
eprintln!("RESULT project secret after remove: deleted_date {:?}", sm.deleted_date());
assert!(sm.deleted_date().is_some(), "the secret is scheduled for deletion");
// R10: deleted at once, so the next start can create it again.
// The forced delete completes asynchronously; give it a moment.
let secret_gone = poll(Duration::from_secs(60), Duration::from_secs(5), || async {
match t.e.secrets.describe_secret().secret_id(project_secret_name(&name, &okey, &id)).send().await {
Err(e) if e.as_service_error().is_some_and(|s| s.is_resource_not_found_exception()) => Some(()),
_ => None,
}
})
.await;
eprintln!("RESULT project secret after remove: gone {secret_gone:?}");
assert!(secret_gone.is_some(), "the secret is deleted without a recovery window");
let defs = ok(
"list the family",
ecs_admin.list_task_definitions().family_prefix(&family).send().await,
+13 -11
View File
@@ -25,8 +25,6 @@ use super::workspace::WorkspaceApi;
/// The secret key holding the agent token (Task 4's payload).
pub const AGENT_TOKEN_KEY: &str = "TRIPLEC_AGENT_TOKEN";
/// Secrets Manager's recovery window when a project is removed.
pub const SECRET_RECOVERY_DAYS: i64 = 7;
/// A project secret is at most 64 KiB; anything bigger is not ours.
const MAX_SECRET_READ: usize = 70_000;
@@ -51,8 +49,10 @@ pub trait RuntimeApi: Send + Sync {
&self,
id: &str,
) -> impl Future<Output = Result<Option<String>, AwsError>> + Send;
/// Schedule deletion with a [`SECRET_RECOVERY_DAYS`] window. A secret
/// that does not exist is success.
/// Delete at once (`ForceDeleteWithoutRecovery`, ruling R10): a secret
/// left pending deletion would make the project's next start fail, and
/// the app rebuilds it from local data. A secret that does not exist is
/// success.
fn delete_secret(&self, name: &str) -> impl Future<Output = Result<(), AwsError>> + Send;
/// A missing access point is success.
fn delete_access_point(&self, id: &str) -> impl Future<Output = Result<(), AwsError>> + Send;
@@ -234,13 +234,15 @@ pub struct RemoveRequest<'a> {
/// missed it).
pub stored_task_arn: Option<&'a str>,
pub stored_access_point_id: Option<&'a str>,
/// Delete the EFS access point. Its data stays on the file system until
/// an administrator removes it; the path is not reused.
/// Delete the EFS access point (ruling R9). The files stay on the
/// user's own file system (only their task role can read it) until
/// offboarding destroys it; a later start of the same project gets a new
/// access point onto the same directory.
pub discard_data: bool,
}
/// Stop the project's task, schedule its secret for deletion (7 days) and,
/// with `discard_data`, delete its access point. Task definition revisions
/// Stop the project's task, delete its secret (no recovery window, R10) and,
/// with `discard_data`, delete its access point (not the files, R9). Task definition revisions
/// are left registered (R8). A task that can't be stopped stops the removal (nothing
/// billed may be left running); the rest is attempted in full and every
/// failure reported.
@@ -417,8 +419,7 @@ impl RuntimeApi for SdkRuntimeApi {
.secrets
.delete_secret()
.secret_id(name)
.force_delete_without_recovery(false)
.recovery_window_in_days(SECRET_RECOVERY_DAYS)
.force_delete_without_recovery(true)
.send()
.await
{
@@ -429,7 +430,8 @@ impl RuntimeApi for SdkRuntimeApi {
{
Ok(())
}
// Already scheduled: the goal.
// Scheduled by an older version of the app and AWS refused the
// forced delete: nothing more this tier may do (no RestoreSecret).
Err(e)
if e.as_service_error().is_some_and(|s| {
s.is_invalid_request_exception()
@@ -715,7 +715,8 @@ pub async fn remove_project(
// An AWS project's task and resources go first, and a failure keeps the
// project: its record is the only handle on a billed task and its
// secret. Its data (the EFS access point) goes only when asked.
// secret. Its EFS access point goes only when asked (the files stay on the
// user's own file system until offboarding).
if let Some(project) = state.projects_store.get(&project_id).filter(|p| p.is_aws()) {
let settings = state.settings_store.get();
if let Some(target) = ContainerTarget::for_project(&project) {
+1 -1
View File
@@ -820,7 +820,7 @@ pub async fn stop_project(project: &Project, settings: &AppSettings) -> Result<(
// ────────────────────────────────────────────────────────────── remove
/// Stop the task and remove the project's AWS resources (task definition
/// revisions, the secret with a 7-day window, and with `discard_data` the
/// revisions, the secret at once, and with `discard_data` the
/// access point). The tunnel is closed once that succeeded; on failure the
/// project keeps it.
pub async fn remove_resources(
+2 -2
View File
@@ -131,8 +131,8 @@ impl ProjectHost {
}
/// AWS: stop the task and remove the project's resources — task
/// definition revisions, the secret (7-day recovery window) and, only
/// with `discard_data`, the EFS access point. Docker: nothing (its state
/// definition revisions, the secret (deleted at once) and, only
/// with `discard_data`, the EFS access point (not its files). Docker: nothing (its state
/// goes with [`Self::discard_project_state`]).
pub async fn remove_aws_resources(
&self,
@@ -3,10 +3,10 @@ import { render, screen, fireEvent } from "@testing-library/react";
import ConfirmRemoveModal, { ConfirmForgetAwsModal } from "./ConfirmRemoveModal";
describe("ConfirmRemoveModal", () => {
it("keeps an AWS workspace's saved files unless asked", () => {
it("keeps an AWS workspace's access point unless asked", () => {
const onConfirm = vi.fn();
render(<ConfirmRemoveModal projectName="api" aws savedFiles onConfirm={onConfirm} onCancel={vi.fn()} />);
const box = screen.getByRole("checkbox", { name: /saved files \(EFS\)/ });
const box = screen.getByRole("checkbox", { name: /file-system access point/ });
expect(box).not.toBeChecked();
fireEvent.click(screen.getByRole("button", { name: "Remove" }));
fireEvent.click(box);
@@ -14,7 +14,7 @@ describe("ConfirmRemoveModal", () => {
expect(onConfirm.mock.calls).toEqual([[{ discardData: false }], [{ discardData: true }]]);
});
it("offers no EFS choice for an Ephemeral AWS workspace", () => {
it("offers no access-point choice for an Ephemeral AWS workspace", () => {
const onConfirm = vi.fn();
render(<ConfirmRemoveModal projectName="api" aws onConfirm={onConfirm} onCancel={vi.fn()} />);
expect(screen.queryByRole("checkbox")).toBeNull();
@@ -22,7 +22,7 @@ describe("ConfirmRemoveModal", () => {
expect(onConfirm).toHaveBeenCalledWith({ discardData: false });
});
it("offers no EFS choice for a local project", () => {
it("offers no access-point choice for a local project", () => {
render(<ConfirmRemoveModal projectName="api" onConfirm={vi.fn()} onCancel={vi.fn()} />);
expect(screen.queryByRole("checkbox")).toBeNull();
expect(screen.getByText(/mounted in, not copied/)).toBeInTheDocument();
@@ -6,7 +6,7 @@ interface Props {
projectName: string;
/** An AWS project: its task, task definitions and secret go instead of Docker state. */
aws?: boolean;
/** AWS: the workspace may have saved files on EFS (offers deleting them). */
/** AWS: the workspace may have an EFS access point (offers removing it). */
savedFiles?: boolean;
onConfirm: (opts: { discardData: boolean }) => void;
onCancel: () => void;
@@ -48,8 +48,7 @@ export default function ConfirmRemoveModal({
<p className="text-[13px] text-[var(--text-secondary)]">
Are you sure you want to remove{" "}
<strong className="text-[var(--text-primary)]">{projectName}</strong>? This stops its
workspace on AWS and removes its secret (deleted after AWS&rsquo;s 7-day recovery
window). Its task definitions stay registered (they hold no secrets and cost
workspace on AWS and deletes its secret. Its task definitions stay registered (they hold no secrets and cost
nothing); an administrator can deregister them. Work that was not pushed to a
remote is lost.
</p>
@@ -62,10 +61,11 @@ export default function ConfirmRemoveModal({
onChange={(e) => setDiscardData(e.target.checked)}
/>
<span>
Also delete the workspace&rsquo;s saved files (EFS)
Also remove the workspace&rsquo;s file-system access point
<span className="block text-xs text-[var(--text-secondary)]">
The Claude login, history and SSH keys kept between starts. Left in place
otherwise.
The saved files themselves (Claude login, history, SSH keys) stay on your own
EFS file system, readable only by your workspace role, until an administrator
offboards you.
</span>
</span>
</label>
@@ -159,7 +159,7 @@ describe("HostSection", () => {
fireEvent.click(screen.getByRole("button", { name: "Remove AWS resources…" }));
const dialog = screen.getByRole("dialog");
// Hybrid: the saved files can go too.
// Hybrid: the access point can go too (the files stay on the user's EFS).
fireEvent.click(within(dialog).getByRole("checkbox"));
fireEvent.click(within(dialog).getByRole("button", { name: "Remove" }));
await waitFor(() => expect(removeAwsResources).toHaveBeenCalledWith(p.id, true));
@@ -401,9 +401,9 @@ function RemoveAwsResourcesModal({ project, onClose }: { project: Project; onClo
>
<p className="text-[13px] text-[var(--text-secondary)]">
Removes <strong className="text-[var(--text-primary)]">{project.name}</strong>&rsquo;s
secret from AWS (after a 7-day recovery window) and keeps the project, so it can run
somewhere else. Its task definitions stay registered for an administrator to
deregister. Its next start on AWS sets everything up again.
secret from AWS and keeps the project, so it can run somewhere else. Its task
definitions stay registered for an administrator to deregister. Its next start on AWS
sets everything up again.
</p>
{hasSavedFiles(project) && (
<label className="mt-3 flex items-start gap-2 text-[13px] text-[var(--text-primary)]">
@@ -413,7 +413,13 @@ function RemoveAwsResourcesModal({ project, onClose }: { project: Project; onClo
checked={discardData}
onChange={(e) => setDiscardData(e.target.checked)}
/>
<span>Also delete the workspace&rsquo;s saved files (EFS)</span>
<span>
Also remove the workspace&rsquo;s file-system access point
<span className="block text-xs text-[var(--text-secondary)]">
The files stay on your own EFS file system (only your workspace role can read
them) until an administrator offboards you.
</span>
</span>
</label>
)}
{error && (
+2 -1
View File
@@ -116,7 +116,8 @@ export interface NewProjectHost {
}
export interface RemoveProjectOptions {
/** AWS: also delete the workspace's saved files (its EFS access point). */
/** AWS: also remove the workspace's EFS access point (the files stay on the
* user's own file system until offboarding). */
discardData?: boolean;
/** AWS: the connection is gone; remove the project and leave its AWS resources. */
forgetAwsResources?: boolean;
+10 -1
View File
@@ -89,6 +89,15 @@ following:
tagged `CreateAccessPoint` needs is authorized against the **file system**, not the new access
point (verified live, phase 5), so `TagOwnAccessPointsAtCreate` names `file-system/*` and is
confined by `elasticfilesystem:CreateAction = CreateAccessPoint`.
- **What removing a project removes.** Removing a project (or only its AWS resources) stops its
task and deletes its secret **at once** (`ForceDeleteWithoutRecovery`, ruling R10: the app
rebuilds it from local data, and a secret left pending deletion would make the next start's
`CreateSecret` fail). "Also remove the workspace's file-system access point" deletes only the
**access point** (ruling R9): the files under it (the Claude login, history, SSH keys) stay on
the user's own EFS file system, which only their own task role can read, until the user is
offboarded (destroying their onboarding module removes the file system). Starting the same
project on AWS again creates a new access point onto the same directory. Task definition
revisions stay registered (R8).
- **Set only the ordinary tag keys.** Every request that tags something may set only
`triple-c:owner`, `triple-c:project` and `triple-c:environment` (`aws:TagKeys`). This applies to
`RunTask`, the ECS and EFS tag-on-create calls, `CreateSecret`, and secret `TagResource`. A
@@ -586,5 +595,5 @@ and the secret and removes the ECR policy; then the fixture destroys the modules
| `~/.claude.json` after Claude Code runs | ✓ still a link (Claude Code started without a login: "Not logged in") |
| Bubblewrap (P9) | ✗ `bwrap --unshare-user` fails: "No permissions to create new namespace" (kernel 6.1, `max_user_namespaces` 16384, no `CAP_SYS_ADMIN` on Fargate). The sandbox stays off on AWS |
| A revision per configuration | turning idle stop on adds a secret key, so the next start registers a new revision (by design) |
| Removal (R8) | ✓ final run: `remove_aws_resources` succeeds; the secret is scheduled for deletion, the access point deleted, the revision left ACTIVE |
| Removal (R8) | ✓ final run: `remove_aws_resources` succeeds; the secret is scheduled for deletion, the access point deleted, the revision left ACTIVE. Since R10 the secret is deleted without a recovery window (the test now asserts it is gone) |
| Cleanup | ✓ nothing `triple-c` left in us-west-2; environment KMS keys pending deletion |