grada-run 0.49.9 → 0.49.11

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.
@@ -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> --query ARN --output text. 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>) 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> --query ARN --output text. Grada only force-deletes when you explicitly choose it: the window protects against accidental loss.',
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
 
@@ -76,6 +76,9 @@ jobs:
76
76
  # point at an unpushed tag), but the repository itself is
77
77
  # Terraform-managed — so it is bootstrapped with a targeted apply
78
78
  # first. Idempotent on existing stacks.
79
+ - name: Setup Terraform
80
+ uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
81
+
79
82
  - name: Bootstrap ECR repository
80
83
  working-directory: ./terraform
81
84
  run: |
@@ -80,6 +80,9 @@ jobs:
80
80
  # start tasks on an unpushed tag), but the repository itself is
81
81
  # Terraform-managed — so it is bootstrapped with a targeted apply
82
82
  # first. Idempotent on existing stacks.
83
+ - name: Setup Terraform
84
+ uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
85
+
83
86
  - name: Bootstrap ECR repository
84
87
  working-directory: ./terraform
85
88
  run: |
@@ -48,6 +48,9 @@ jobs:
48
48
  terraform_wrapper: false
49
49
 
50
50
  - name: Terraform Init
51
+ # Without creds there is nothing to init against: skip with the
52
+ # notice above instead of failing red on the S3 backend.
53
+ if: steps.aws-creds.outcome == 'success'
51
54
  working-directory: ./terraform
52
55
  run: terraform init -input=false
53
56