grada-run 0.49.8 → 0.49.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/apply.js +137 -115
- package/src/commands/init.js +1023 -834
- package/src/utils/recovery.js +35 -1
- package/src/utils/terraform-errors.js +2 -2
package/src/utils/recovery.js
CHANGED
|
@@ -3,7 +3,41 @@ import path from 'path';
|
|
|
3
3
|
import { confirm, isCancel } from '@clack/prompts';
|
|
4
4
|
import { ensureStateBucketExists } from './aws.js';
|
|
5
5
|
import { parseStateBucketBackend } from './terraform-metadata.js';
|
|
6
|
-
import { refuseIfNonInteractive } from './command.js';
|
|
6
|
+
import { refuseIfNonInteractive, shouldAutoApprove } from './command.js';
|
|
7
|
+
|
|
8
|
+
// confirm() with the recovery defaults: preselected yes, cancel-safe,
|
|
9
|
+
// resolving to a plain boolean.
|
|
10
|
+
export async function confirmRecoveryAction(message) {
|
|
11
|
+
const confirmed = await confirm({ message, initialValue: true });
|
|
12
|
+
return !isCancel(confirmed) && confirmed === true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Runs one in-flow recovery round — refuse-if-headless, approve (auto or
|
|
16
|
+
// prompt), act — and reports a discriminated outcome so callers keep owning
|
|
17
|
+
// their own retry + runbook rendering:
|
|
18
|
+
//
|
|
19
|
+
// - { status: 'refused', refusal } — propagate the refusal result as-is.
|
|
20
|
+
// - { status: 'recovered', method } — act succeeded; retry the command.
|
|
21
|
+
// - { status: 'declined' } — user declined/dismissed; show manual guidance.
|
|
22
|
+
// - { status: 'failed', method, error } — act threw; show guidance + cause.
|
|
23
|
+
//
|
|
24
|
+
// `approve` runs only when --auto-approve is off and resolves to a truthy
|
|
25
|
+
// method (confirm) or a method string (select), falsy on decline.
|
|
26
|
+
// `autoMethod` is the method taken non-interactively. `act` receives the
|
|
27
|
+
// resolved method; anything it needs beyond that (flags for the fallthrough
|
|
28
|
+
// notes) it sets through the caller's own scope.
|
|
29
|
+
export async function offerInFlowRecovery({ options, refusal, approve, autoMethod = true, act }) {
|
|
30
|
+
const refused = await refuseIfNonInteractive(options, refusal);
|
|
31
|
+
if (refused) return { status: 'refused', refusal: refused };
|
|
32
|
+
const method = shouldAutoApprove(options) ? autoMethod : await approve();
|
|
33
|
+
if (!method) return { status: 'declined' };
|
|
34
|
+
try {
|
|
35
|
+
await act(method);
|
|
36
|
+
return { status: 'recovered', method };
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return { status: 'failed', method, error };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
7
41
|
|
|
8
42
|
// Asks whether to recreate a missing state bucket and resume
|
|
9
43
|
// provisioning. Returns true when approved. Has no side effects
|
|
@@ -161,8 +161,8 @@ const RUNBOOKS = {
|
|
|
161
161
|
},
|
|
162
162
|
SECRET_PENDING_DELETION: {
|
|
163
163
|
message: 'A Secrets Manager secret is scheduled for deletion.',
|
|
164
|
-
headless: 'Restore it (aws secretsmanager restore-secret --secret-id <name>, then cd terraform && terraform import \'aws_secretsmanager_secret.app_secrets[0]\' <arn>) or force-delete without recovery (aws secretsmanager delete-secret --secret-id <name> --force-delete-without-recovery) and re-apply + push — fetch the ARN via aws secretsmanager describe-secret --secret-id <name>
|
|
165
|
-
interactive: 'Restore it (aws secretsmanager restore-secret --secret-id <name>, then cd terraform && terraform import \'aws_secretsmanager_secret.app_secrets[0]\' <arn>) or force-delete without recovery (aws secretsmanager delete-secret --secret-id <name> --force-delete-without-recovery) and re-apply + push — fetch the ARN via aws secretsmanager describe-secret --secret-id <name>
|
|
164
|
+
headless: 'Restore it (aws secretsmanager restore-secret --secret-id <name>, then cd terraform && terraform import \'aws_secretsmanager_secret.app_secrets[0]\' <arn> and terraform import \'aws_secretsmanager_secret_version.app_secrets_initial[0]\' \'<arn>|<version-id>\') or force-delete without recovery (aws secretsmanager delete-secret --secret-id <name> --force-delete-without-recovery) and re-apply + push — fetch the ARN and the live version id via aws secretsmanager describe-secret --secret-id <name> (the ARN, plus the version staged AWSCURRENT under VersionIdsToStages); after re-applying, run secrets audit and re-push if values look wrong. Grada only force-deletes when you explicitly choose it: the window protects against accidental loss.',
|
|
165
|
+
interactive: 'Restore it (aws secretsmanager restore-secret --secret-id <name>, then cd terraform && terraform import \'aws_secretsmanager_secret.app_secrets[0]\' <arn> and terraform import \'aws_secretsmanager_secret_version.app_secrets_initial[0]\' \'<arn>|<version-id>\') or force-delete without recovery (aws secretsmanager delete-secret --secret-id <name> --force-delete-without-recovery) and re-apply + push — fetch the ARN and the live version id via aws secretsmanager describe-secret --secret-id <name> (the ARN, plus the version staged AWSCURRENT under VersionIdsToStages); after re-applying, run secrets audit and re-push if values look wrong. Grada only force-deletes when you explicitly choose it: the window protects against accidental loss.',
|
|
166
166
|
},
|
|
167
167
|
};
|
|
168
168
|
|