grada-run 0.49.3 → 0.49.5
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/add.js +1 -1
- package/src/commands/alerts.js +1 -1
- package/src/commands/apply.js +2 -2
- package/src/commands/db/backup.js +3 -3
- package/src/commands/db/connect.js +2 -2
- package/src/commands/db/enable-vector.js +1 -1
- package/src/commands/db/import.js +2 -2
- package/src/commands/db/migrate.js +7 -6
- package/src/commands/destroy.js +6 -6
- package/src/commands/diagnose.js +1 -1
- package/src/commands/domain.js +2 -2
- package/src/commands/exec.js +1 -1
- package/src/commands/gc.js +2 -2
- package/src/commands/init.js +7 -7
- package/src/commands/logs.js +3 -3
- package/src/commands/rollback.js +4 -4
- package/src/commands/secrets.js +18 -18
- package/src/commands/status.js +3 -3
- package/src/commands/wake.js +2 -2
- package/src/utils/addons.js +1 -1
- package/src/utils/backup.js +1 -1
- package/src/utils/ecs-runner.js +3 -3
- package/src/utils/generator.js +3 -3
- package/src/utils/prompts.js +1 -1
- package/src/utils/resolvers.js +8 -10
- package/src/utils/terraform.js +1 -1
- package/templates/github/deploy-lambda.yml +2 -2
- package/templates/github/deploy-static.yml +1 -1
- package/templates/github/deploy.yml +2 -2
- package/templates/github/drift.yml +1 -1
- package/templates/github/plan.yml +2 -2
- package/templates/github/preview-lambda.yml +4 -4
- package/templates/github/preview.yml +4 -4
- package/templates/github/teardown.yml +3 -3
- package/templates/terraform/addons/bedrock.tf +1 -1
- package/templates/terraform/backend.tf +1 -1
- package/templates/terraform/cloudfront-lambda.tf +2 -2
- package/templates/terraform/cloudfront.tf +3 -3
- package/templates/terraform/database-aurora-postgresql.tf +1 -1
- package/templates/terraform/main.tf +3 -3
- package/templates/terraform/oidc.tf +62 -40
- package/templates/terraform/secrets.tf +1 -1
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -706,7 +706,7 @@ export function renderWorkerAutoscalingBlock(hasWorker) {
|
|
|
706
706
|
function renderAddonTemplate(templateContent, templateVars = {}, conditionalBlocks = {}) {
|
|
707
707
|
let rendered = String(templateContent ?? '');
|
|
708
708
|
// Replacement FUNCTIONS (not strings): `$` patterns in values (cron
|
|
709
|
-
// commands, ARNs) land byte-identical
|
|
709
|
+
// commands, ARNs) land byte-identical.
|
|
710
710
|
for (const [key, value] of Object.entries(templateVars)) {
|
|
711
711
|
const literal = String(value ?? '');
|
|
712
712
|
rendered = rendered.replaceAll(`{{${key}}}`, () => literal);
|
package/src/commands/alerts.js
CHANGED
|
@@ -187,7 +187,7 @@ export function buildAlertsTf({ projectName, target = 'ecs', email, webhook, thr
|
|
|
187
187
|
const defaults = ALERT_TARGET_DEFAULTS[target] || ALERT_TARGET_DEFAULTS.ecs;
|
|
188
188
|
const limit = threshold ?? defaults.threshold;
|
|
189
189
|
// All targets use the workspace-aware local: flat ECS names let a
|
|
190
|
-
// preview apply clobber the prod alarm
|
|
190
|
+
// preview apply clobber the prod alarm. Existing trees
|
|
191
191
|
// migrate on the next `grada alerts` + apply (topic/alarm recreate).
|
|
192
192
|
const namePrefix = '${local.app_name}';
|
|
193
193
|
const aliasLine = target === 'static' ? ' provider = aws.us_east_1\n' : '';
|
package/src/commands/apply.js
CHANGED
|
@@ -492,7 +492,7 @@ async function applyStackMain(input = {}) {
|
|
|
492
492
|
if (!sleepGuard.proceed) return sleepGuard.result;
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
// 1d. Preflight secret/env collisions
|
|
495
|
+
// 1d. Preflight secret/env collisions: stale,
|
|
496
496
|
// confirmed-through, or hand-edited keys files would die late on
|
|
497
497
|
// the raw ECS 400 — fail here naming the key and the fix. ECS-only
|
|
498
498
|
// (Lambda maps no secrets into env), unconditional (a collision is
|
|
@@ -671,7 +671,7 @@ async function applyStackMain(input = {}) {
|
|
|
671
671
|
if (cfUrl) finalMessage += `\n 🌍 App URL: ${color.cyan(cfUrl)} ${color.dim('(global CDN — share this link)')}`;
|
|
672
672
|
// The origin only answers CloudFront (listener rule 403s direct
|
|
673
673
|
// hits without the origin-secret header) — label the URL as
|
|
674
|
-
// unreachable instead of a working bypass
|
|
674
|
+
// unreachable instead of a working bypass.
|
|
675
675
|
if (albUrl) finalMessage += `\n 🚦 Direct URL: ${color.gray(albUrl)} ${color.dim('(CloudFront-only origin — direct hits 403)')}`;
|
|
676
676
|
// Lambda stacks have no CDN: without a CloudFront URL the API
|
|
677
677
|
// URL is the primary link, not a debug bypass.
|
|
@@ -33,7 +33,7 @@ function snapshotSourceDb(snapshot, isCluster) {
|
|
|
33
33
|
return isCluster ? snapshot.DBClusterIdentifier : snapshot.DBInstanceIdentifier;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// The reused id names another database's snapshot.
|
|
37
37
|
// Shared by the wait and no-wait paths (they differ only in `waited`).
|
|
38
38
|
function failSnapshotMismatch({ spinnerHandle, snapshotId, foreignDb, targetId, projectName, waited, dbIdentifier, region }) {
|
|
39
39
|
spinnerHandle.stop(color.red('❌ Snapshot belongs to another database.'));
|
|
@@ -202,7 +202,7 @@ async function runDbBackupMain(input = {}) {
|
|
|
202
202
|
|
|
203
203
|
if (noWait) {
|
|
204
204
|
if (reusedExisting) {
|
|
205
|
-
//
|
|
205
|
+
// Verify ownership even when not waiting — one
|
|
206
206
|
// describe, fail closed on a foreign snapshot. A
|
|
207
207
|
// not-found here is transient (eventual consistency),
|
|
208
208
|
// so only proceed past it.
|
|
@@ -268,7 +268,7 @@ async function runDbBackupMain(input = {}) {
|
|
|
268
268
|
throw error;
|
|
269
269
|
}
|
|
270
270
|
const snapshot = snapshots[0] || null;
|
|
271
|
-
//
|
|
271
|
+
// An explicit --id can name another database's
|
|
272
272
|
// snapshot (AlreadyExists proves existence, not
|
|
273
273
|
// ownership) — fail closed instead of adopting a
|
|
274
274
|
// foreign snapshot as our safety backup. Checked
|
|
@@ -272,7 +272,7 @@ async function runDbConnectMain(input = {}) {
|
|
|
272
272
|
});
|
|
273
273
|
|
|
274
274
|
// Node reports signal death as code null — a killed tunnel is a
|
|
275
|
-
// failure naming the signal, never `?? 0` success
|
|
275
|
+
// failure naming the signal, never `?? 0` success.
|
|
276
276
|
const { code, signal } = await new Promise((resolve) => {
|
|
277
277
|
const child = spawnImpl('aws', ssmArgs, { stdio: 'inherit' });
|
|
278
278
|
child.on('error', (err) => {
|
|
@@ -288,7 +288,7 @@ async function runDbConnectMain(input = {}) {
|
|
|
288
288
|
// Telemetry carries only non-sensitive fields. Credentials never leave this process
|
|
289
289
|
// except to the terminal above and the local SSM session below.
|
|
290
290
|
// Success is recorded only for a clean tunnel exit: a failed tunnel
|
|
291
|
-
// reports the tunnel's own exit code instead of ok:true
|
|
291
|
+
// reports the tunnel's own exit code instead of ok:true.
|
|
292
292
|
if (code !== 0) {
|
|
293
293
|
const tunnelCode = Number.isInteger(code) && code > 0 ? Math.min(code, 255) : 1;
|
|
294
294
|
return failCommand({
|
|
@@ -322,7 +322,7 @@ async function runDbEnableVectorMain(input = {}) {
|
|
|
322
322
|
const exitCode = outcome.exitCode;
|
|
323
323
|
const stoppedReason = outcome.stoppedReason;
|
|
324
324
|
if (exitCode === 0) {
|
|
325
|
-
// Owner pairs its own start/stop
|
|
325
|
+
// Owner pairs its own start/stop: a callee must never stop its caller's spinner.
|
|
326
326
|
try { s.stop(color.green('pgvector extension enabled.')); } catch { /* already stopped */ }
|
|
327
327
|
console.log(color.green('\n✅ pgvector extension enabled.'));
|
|
328
328
|
try {
|
|
@@ -159,7 +159,7 @@ function targetEnv(targetScheme, password) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
// Source-side dump env: the SOURCE is arbitrary user infra (often no
|
|
162
|
-
// TLS), so prefer TLS instead of requiring it
|
|
162
|
+
// TLS), so prefer TLS instead of requiring it. MySQL sources
|
|
163
163
|
// were never forced; the target side keeps `require`.
|
|
164
164
|
function sourceEnv(scheme, password) {
|
|
165
165
|
if (scheme === 'mysql') {
|
|
@@ -172,7 +172,7 @@ function waitForExit(child) {
|
|
|
172
172
|
return new Promise((resolve) => {
|
|
173
173
|
child.once('error', (error) => resolve({ code: 1, error }));
|
|
174
174
|
// Node reports signal death as code null — resolve it as failure
|
|
175
|
-
// (with the signal), never `?? 0` success
|
|
175
|
+
// (with the signal), never `?? 0` success.
|
|
176
176
|
child.once('close', (code, signal) => resolve(signal ? { code: 1, signal } : { code: code ?? 0 }));
|
|
177
177
|
});
|
|
178
178
|
}
|
|
@@ -101,7 +101,7 @@ function renderGateBlock({ includeSetupNode, steps }) {
|
|
|
101
101
|
lines.push(
|
|
102
102
|
` - name: ${stepName}`,
|
|
103
103
|
// Gates run AWS calls: honor the credential-skip outcome like
|
|
104
|
-
// every other post-assume step
|
|
104
|
+
// every other post-assume step. Neutral on deploy
|
|
105
105
|
// (a failed assume fails the run before any gate runs).
|
|
106
106
|
` if: steps.aws-creds.outcome == 'success'`,
|
|
107
107
|
' run: |',
|
|
@@ -147,7 +147,7 @@ function injectGateBlock(content, { steps, anchor }) {
|
|
|
147
147
|
// Idempotently injects (or refreshes) the migration gate block into a
|
|
148
148
|
// deploy.yml document. Returns the updated content, or null when neither
|
|
149
149
|
// anchor step is present. Pure and unit-tested. The snapshot id embeds
|
|
150
|
-
// the database identifier
|
|
150
|
+
// the database identifier: bare pre-deploy-<sha> ids match no
|
|
151
151
|
// guardrail or gc name pattern, so they were never protected or retired.
|
|
152
152
|
export function injectMigrationGate(workflowContent, { cmd, cliVersion, dbIdentifier } = {}) {
|
|
153
153
|
if (typeof dbIdentifier !== 'string' || dbIdentifier.trim() === '') {
|
|
@@ -297,7 +297,7 @@ async function runDbMigrateMain(input = {}) {
|
|
|
297
297
|
|
|
298
298
|
// 2. --setup-ci: patch the workflow file, no AWS calls.
|
|
299
299
|
if (setupCi) {
|
|
300
|
-
//
|
|
300
|
+
// The gate runs migrations as an ephemeral ECS task —
|
|
301
301
|
// refuse on lambda/static (no ECS to run on). Init auto-skips
|
|
302
302
|
// with a warning; this explicit command fails closed.
|
|
303
303
|
const setupTarget = readTerraformComputeTarget(cwd);
|
|
@@ -328,12 +328,13 @@ async function runDbMigrateMain(input = {}) {
|
|
|
328
328
|
resultExtra: { cluster, service, region },
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
|
-
//
|
|
331
|
+
// The gate always targets production (deploy.yml), so
|
|
332
332
|
// resolve the prod db id even with a preview workspace checked
|
|
333
333
|
// out locally. Aurora needs the cluster prefix: cluster
|
|
334
334
|
// snapshots named with the instance prefix would miss the
|
|
335
335
|
// cluster-snapshot guardrail pattern.
|
|
336
|
-
const
|
|
336
|
+
const setupDbKind = readTerraformDbKind(cwd);
|
|
337
|
+
const setupDbResolver = setupDbKind === 'cluster' ? resolveDbClusterIdentifier : resolveDbIdentifier;
|
|
337
338
|
const setupDbIdentifier = setupDbResolver({ projectName, workspace: 'default' }, cwd);
|
|
338
339
|
const updated = injectMigrationGate(workflowContent, { cmd: resolvedCmd, cliVersion: getCliVersion(), dbIdentifier: setupDbIdentifier });
|
|
339
340
|
if (updated === null) {
|
|
@@ -367,7 +368,7 @@ async function runDbMigrateMain(input = {}) {
|
|
|
367
368
|
}
|
|
368
369
|
}
|
|
369
370
|
}
|
|
370
|
-
await trackSuccess('db_migrate_run', { projectName, cmd_source: cmdSource, ci_setup: true });
|
|
371
|
+
await trackSuccess('db_migrate_run', { projectName, cmd_source: cmdSource, ci_setup: true, db_kind: setupDbKind });
|
|
371
372
|
outro(color.green('Setup complete.'));
|
|
372
373
|
return { ok: true, ciSetup: true, workflowFile, cmdSource };
|
|
373
374
|
}
|
package/src/commands/destroy.js
CHANGED
|
@@ -123,7 +123,7 @@ export async function handleDestroyTerraformError({ options, tfDirPath, attemptD
|
|
|
123
123
|
return namedFail('STATE_LOCK_HELD');
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
//
|
|
126
|
+
// A drained bucket can still report versions when terraform
|
|
127
127
|
// runs (S3 empty-visibility race). Settle briefly, then retry the
|
|
128
128
|
// destroy exactly once — a second BucketNotEmpty is terminal.
|
|
129
129
|
if (code === 'BUCKET_NOT_EMPTY') {
|
|
@@ -447,11 +447,11 @@ async function destroyStackMain(input = {}) {
|
|
|
447
447
|
}
|
|
448
448
|
// Wait for the snapshot to reach `available` before touching the
|
|
449
449
|
// database: deleting while it is still `creating` races snapshot
|
|
450
|
-
// completion on large DBs
|
|
450
|
+
// completion on large DBs. A failed snapshot or a timeout
|
|
451
451
|
// refuses the destroy — re-run with --allow-data-loss to skip.
|
|
452
452
|
// Re-message (never re-start): the phase spinner is already
|
|
453
453
|
// running, and a second start leaks clack's first interval so the
|
|
454
|
-
// session never exits
|
|
454
|
+
// session never exits.
|
|
455
455
|
s.message(truncateSpinnerText(`Waiting for snapshot ${snapshotId} to complete...`));
|
|
456
456
|
const snapshotReady = await pollUntil({
|
|
457
457
|
intervalMs: pollIntervalMs,
|
|
@@ -477,7 +477,7 @@ async function destroyStackMain(input = {}) {
|
|
|
477
477
|
if (status === 'failed' || status === 'deleted') {
|
|
478
478
|
return { done: true, value: { failed: true, reason: `snapshot ${status}` } };
|
|
479
479
|
}
|
|
480
|
-
//
|
|
480
|
+
// Surface PercentProgress while creating so long
|
|
481
481
|
// snapshots don't look wedged.
|
|
482
482
|
const detail = typeof percent === 'number' ? `${status || 'pending'} (${percent}% complete)` : (status || 'pending');
|
|
483
483
|
s.message(truncateSpinnerText(`Waiting for snapshot ${snapshotId} to complete... (${detail})`));
|
|
@@ -613,7 +613,7 @@ async function destroyStackMain(input = {}) {
|
|
|
613
613
|
resultExtra: { region },
|
|
614
614
|
});
|
|
615
615
|
}
|
|
616
|
-
//
|
|
616
|
+
// Versioned deletes can lag S3's empty-reads, so
|
|
617
617
|
// verify each drained bucket reads empty before terraform
|
|
618
618
|
// destroy runs — otherwise destroy flakes on BucketNotEmpty.
|
|
619
619
|
// A bucket deleted out-of-band counts as empty.
|
|
@@ -690,7 +690,7 @@ async function destroyStackMain(input = {}) {
|
|
|
690
690
|
});
|
|
691
691
|
if (refused) return refused;
|
|
692
692
|
}
|
|
693
|
-
//
|
|
693
|
+
// "spin this back up" overstated recovery — apply
|
|
694
694
|
// recreates compute, never the destroyed database. Name the
|
|
695
695
|
// snapshot (or its absence) so the choice is informed.
|
|
696
696
|
const dbRecoveryNote = snapshotReadyId
|
package/src/commands/diagnose.js
CHANGED
|
@@ -262,7 +262,7 @@ async function runDiagnoseMain(input = {}) {
|
|
|
262
262
|
cwd = resolveCwd(options);
|
|
263
263
|
projectName = resolveProjectName(options, cwd);
|
|
264
264
|
region = resolveRegion(options, cwd);
|
|
265
|
-
// Workspace-namespaced resources
|
|
265
|
+
// Workspace-namespaced resources: --workspace (or the
|
|
266
266
|
// local .terraform/environment) targets a preview stack like
|
|
267
267
|
// rollback and db do. Explicit flags/env keep winning; telemetry
|
|
268
268
|
// keeps the raw project name.
|
package/src/commands/domain.js
CHANGED
|
@@ -529,7 +529,7 @@ async function runDomainAdd({ options, projectName, domain, zoneId, domainTfPath
|
|
|
529
529
|
cloudfrontPatched = patched.changed;
|
|
530
530
|
} else if (previousDomain && previousDomain !== domain) {
|
|
531
531
|
// External-pending wires nothing new, but a --force replace must
|
|
532
|
-
// still release the previous ACTIVE aliases
|
|
532
|
+
// still release the previous ACTIVE aliases.
|
|
533
533
|
const read = await readCloudFrontDistribution(cloudfrontTfPath, 'add', noExit);
|
|
534
534
|
if (!read.ok) return read.failure;
|
|
535
535
|
const updated = unpatchCloudFrontDomain(read.content, previousDomain);
|
|
@@ -799,7 +799,7 @@ async function runDomainRemove({ options, projectName, domainTfPath, cloudfrontT
|
|
|
799
799
|
console.log(color.yellow(`⚠ ${remainingAliases.length} alias(es) remain (${remainingAliases.join(', ')}): the ACM viewer_certificate is kept, but its validation resource is deleted with domain.tf — rewire the certificate by hand before applying.`));
|
|
800
800
|
} else if (!unpatched) {
|
|
801
801
|
// The aliases were never touched: claiming a restore would send
|
|
802
|
-
// the next apply into a stale-alias failure
|
|
802
|
+
// the next apply into a stale-alias failure.
|
|
803
803
|
console.log(color.green(`\n✅ Custom domain ${domain || ''} removed.`.replace(' ', ' ')));
|
|
804
804
|
const why = !domain
|
|
805
805
|
? 'terraform/domain.tf was unparseable, so CloudFront aliases were left untouched'
|
package/src/commands/exec.js
CHANGED
|
@@ -109,7 +109,7 @@ async function runExecMain(input = {}) {
|
|
|
109
109
|
cwd = resolveCwd(options);
|
|
110
110
|
region = resolveRegion(options, cwd);
|
|
111
111
|
projectName = resolveProjectName(options, cwd);
|
|
112
|
-
// Workspace-namespaced resources
|
|
112
|
+
// Workspace-namespaced resources: --workspace (or the
|
|
113
113
|
// local .terraform/environment) targets a preview stack like
|
|
114
114
|
// rollback and db do — exec into a preview must not land in
|
|
115
115
|
// production. Explicit flags/env keep winning.
|
package/src/commands/gc.js
CHANGED
|
@@ -287,7 +287,7 @@ async function discoverOldManualSnapshots({ rdsClient, dbIdentifier, dbClusterId
|
|
|
287
287
|
.map((id) => id.trim().toLowerCase());
|
|
288
288
|
const patterns = dbIds
|
|
289
289
|
.map((id) => new RegExp(`^${escapeRegExp(id)}-manual-\\d{8}-\\d{6}$`));
|
|
290
|
-
//
|
|
290
|
+
// The gate's pre-deploy snapshots are per-commit, so without
|
|
291
291
|
// a discovery rule they accumulate into the region snapshot quota.
|
|
292
292
|
const predeployPatterns = dbIds
|
|
293
293
|
.map((id) => new RegExp(`^${escapeRegExp(id)}-pre-deploy-[0-9a-f]{7,40}$`));
|
|
@@ -589,7 +589,7 @@ export async function deleteDiscoveredResources(clients, discovered) {
|
|
|
589
589
|
try {
|
|
590
590
|
summary[target.summary] = await target.remove(clients, discovered[target.field] || []);
|
|
591
591
|
} catch (error) {
|
|
592
|
-
// One target's API failure must not strand the rest
|
|
592
|
+
// One target's API failure must not strand the rest:
|
|
593
593
|
// record it, zero its count, and keep deleting.
|
|
594
594
|
errors.push({ target: target.summary, error });
|
|
595
595
|
summary[target.summary] = 0;
|
package/src/commands/init.js
CHANGED
|
@@ -144,7 +144,7 @@ export function resolveDefaultBranch(targetDir, deployBranch, execSyncImpl = exe
|
|
|
144
144
|
// Renders both CI roles' trust claims as HCL fragments from the resolved
|
|
145
145
|
// repo trust: the deploy role binds to the effective deploy branch (the
|
|
146
146
|
// same value rendered into the deploy trigger, so the two stay in sync),
|
|
147
|
-
// the preview role binds to pull request events.
|
|
147
|
+
// the preview role binds to pull request events. Scheduled drift
|
|
148
148
|
// runs on the default branch, so when it differs from the deploy branch
|
|
149
149
|
// the deploy role trusts both refs. The open trust and hand-customized
|
|
150
150
|
// claims render verbatim — never silently widened.
|
|
@@ -193,7 +193,7 @@ export function buildRoleArn(accountId, roleName) {
|
|
|
193
193
|
// dual-format pair resolves back to its classic entry so re-init stays
|
|
194
194
|
// stable; anything richer is described for warnings and guarded against
|
|
195
195
|
// silent widening.
|
|
196
|
-
// Recognizes our own canonical dual-branch trust
|
|
196
|
+
// Recognizes our own canonical dual-branch trust: two classic
|
|
197
197
|
// branch refs for one slug plus each entry's immutable companion, in
|
|
198
198
|
// render order. Returns { deploySub, branches } or null.
|
|
199
199
|
function parseCanonicalDualTrust(entries) {
|
|
@@ -492,7 +492,7 @@ async function mainStackMain(input = {}) {
|
|
|
492
492
|
target = targetAnswer;
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
// Capability-vs-target policy for --with
|
|
495
|
+
// Capability-vs-target policy for --with: refuse fast when
|
|
496
496
|
// the requested capability cannot render on this target (static has
|
|
497
497
|
// no task role or VPC), before any prompt/AWS call/write. Interactive
|
|
498
498
|
// multiselect offers only compatible targets' caps; this covers --with.
|
|
@@ -962,7 +962,7 @@ async function mainStackMain(input = {}) {
|
|
|
962
962
|
|
|
963
963
|
// 7. Synthesize Templates
|
|
964
964
|
s.message('Synthesizing Terraform templates...');
|
|
965
|
-
//
|
|
965
|
+
// Live origin/HEAD wins when it names a real branch; when
|
|
966
966
|
// detection falls back, a re-init keeps the tree's own default branch
|
|
967
967
|
// so dual trust never narrows silently.
|
|
968
968
|
const treeDefaultBranch = oidcResolution.treeBranches?.[1] ?? null;
|
|
@@ -1025,7 +1025,7 @@ async function mainStackMain(input = {}) {
|
|
|
1025
1025
|
if (migrationGateEnabled && migrationCmd) {
|
|
1026
1026
|
const deployYmlPath = path.join(dirConfig.targetDir, '.github', 'workflows', 'deploy.yml');
|
|
1027
1027
|
const workflowContent = readFileSafe(deployYmlPath);
|
|
1028
|
-
//
|
|
1028
|
+
// Scope the gate's snapshot id to the database (aurora
|
|
1029
1029
|
// takes the cluster prefix) so guardrails and gc can name it.
|
|
1030
1030
|
const gateDbRefs = resolveDbEngineRefs(config.dbEngine);
|
|
1031
1031
|
const gateDbIdentifier = `${dirConfig.actualProjectName}${resourceSuffix}-db${gateDbRefs.isCluster ? '-cluster' : ''}`;
|
|
@@ -1053,7 +1053,7 @@ async function mainStackMain(input = {}) {
|
|
|
1053
1053
|
|
|
1054
1054
|
if (driftEnabled) {
|
|
1055
1055
|
// drift.yml rides the manifest + backup like deploy.yml now
|
|
1056
|
-
//
|
|
1056
|
+
// Re-init backs the old file up and regenerates fresh
|
|
1057
1057
|
// (current role ARN) instead of silently keeping a stale copy.
|
|
1058
1058
|
// Hand edits trip refuse-dirty before this point; --force regenerates.
|
|
1059
1059
|
const drifted = scaffoldDriftWorkflow(dirConfig.targetDir, {
|
|
@@ -1235,7 +1235,7 @@ async function mainStackMain(input = {}) {
|
|
|
1235
1235
|
console.log(color.dim(' 💡 Vector-search dependencies detected: managed pgvector support is coming soon.'));
|
|
1236
1236
|
}
|
|
1237
1237
|
// Static targets refuse `add cron` (no compute) — don't send
|
|
1238
|
-
// static users down a dead end
|
|
1238
|
+
// static users down a dead end.
|
|
1239
1239
|
if (upcoming.cron && target !== 'static') {
|
|
1240
1240
|
console.log(color.dim(' 💡 Scheduled-task dependencies detected: scaffold a schedule with "grada add cron".'));
|
|
1241
1241
|
}
|
package/src/commands/logs.js
CHANGED
|
@@ -117,7 +117,7 @@ function eventKey(event) {
|
|
|
117
117
|
|
|
118
118
|
// Fetches the most recent matching events from a log group.
|
|
119
119
|
// FilterLogEvents pages oldest-first, so slicing the first page shows the
|
|
120
|
-
// OLDEST N on groups larger than one page
|
|
120
|
+
// OLDEST N on groups larger than one page. This probes with a
|
|
121
121
|
// small page (cheap when the group fits), and only multi-page groups pay
|
|
122
122
|
// for a wide-page scan to the live edge; a rolling window keeps memory
|
|
123
123
|
// O(tail). Returns `{ events, nextToken }` — the trailing window plus the
|
|
@@ -195,7 +195,7 @@ async function runLogsMain(input = {}) {
|
|
|
195
195
|
try {
|
|
196
196
|
cwd = resolveCwd(options);
|
|
197
197
|
region = resolveRegion(options, cwd);
|
|
198
|
-
// Workspace-namespaced resources
|
|
198
|
+
// Workspace-namespaced resources: --workspace (or the
|
|
199
199
|
// local .terraform/environment) targets a preview stack like
|
|
200
200
|
// rollback and db do. Explicit flags/env keep winning.
|
|
201
201
|
const namespacedOptions = withWorkspaceNamespace(options, cwd);
|
|
@@ -212,7 +212,7 @@ async function runLogsMain(input = {}) {
|
|
|
212
212
|
const isLambda = isComputeTarget(cwd, 'lambda');
|
|
213
213
|
const explicitService = hasExplicitService(options) && !isLambda;
|
|
214
214
|
|
|
215
|
-
// Explicit garbage fails loud
|
|
215
|
+
// Explicit garbage fails loud: silently substituting defaults
|
|
216
216
|
// for a mistyped --tail/--since shows logs the user never asked for.
|
|
217
217
|
// Absent flags still default via the normalizers below.
|
|
218
218
|
const rawTail = options.tail ?? options.tailLines ?? options.lines;
|
package/src/commands/rollback.js
CHANGED
|
@@ -178,7 +178,7 @@ async function runRollbackMain(input = {}) {
|
|
|
178
178
|
let targetTaskDefArn;
|
|
179
179
|
let targetRevisionNum;
|
|
180
180
|
// Case A only: the requested web revision's image, for worker
|
|
181
|
-
// pairing
|
|
181
|
+
// pairing. Null in Case B and when undescribable.
|
|
182
182
|
let requestedWebImage = null;
|
|
183
183
|
|
|
184
184
|
if (options.revision !== undefined && options.revision !== null && String(options.revision).trim() !== '') {
|
|
@@ -236,7 +236,7 @@ async function runRollbackMain(input = {}) {
|
|
|
236
236
|
exitCode: 1,
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
|
-
//
|
|
239
|
+
// A NEWER explicit revision would silently
|
|
240
240
|
// roll FORWARD — rollback only moves to older revisions.
|
|
241
241
|
if (Number.isInteger(Number(targetRevisionNum)) && Number.isInteger(currentRevNum)
|
|
242
242
|
&& Number(targetRevisionNum) > currentRevNum) {
|
|
@@ -322,7 +322,7 @@ async function runRollbackMain(input = {}) {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
// 1b. Worker rollback
|
|
325
|
+
// 1b. Worker rollback: deploys advance web AND worker,
|
|
326
326
|
// so a rollback must move both — otherwise the worker keeps the bad
|
|
327
327
|
// image. Explicit --service keeps single-service semantics (the
|
|
328
328
|
// escape hatch); workerless trees (no worker.tf) skip. Resolved
|
|
@@ -352,7 +352,7 @@ async function runRollbackMain(input = {}) {
|
|
|
352
352
|
exitCode: 1,
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
|
-
//
|
|
355
|
+
// In Case A the worker target pairs with the
|
|
356
356
|
// REQUESTED web image (deploys pin both to the same SHA) —
|
|
357
357
|
// newest-previous regardless would skew the pairing. When
|
|
358
358
|
// no eligible worker revision carries the web image, fall
|
package/src/commands/secrets.js
CHANGED
|
@@ -64,7 +64,7 @@ function resolveSecretsFile(envFilePath) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
function resolveSecretsProject(projectName) {
|
|
67
|
-
//
|
|
67
|
+
// The terraform project name (what provisioned the vault)
|
|
68
68
|
// outranks the directory basename — a renamed directory otherwise
|
|
69
69
|
// silently aims at a missing vault.
|
|
70
70
|
if (typeof projectName === 'string' && projectName.trim()) return projectName.trim();
|
|
@@ -87,7 +87,7 @@ export async function resolveSecretsRegion(options = {}) {
|
|
|
87
87
|
try {
|
|
88
88
|
const backendTfPath = path.join(process.cwd(), 'terraform', 'backend.tf');
|
|
89
89
|
const backendTfContent = await fs.readFile(backendTfPath, 'utf-8');
|
|
90
|
-
//
|
|
90
|
+
// Scan line-wise skipping comments — the old whole-file
|
|
91
91
|
// regex resolved commented-out regions (or legacy lines) as live.
|
|
92
92
|
for (const rawLine of backendTfContent.split('\n')) {
|
|
93
93
|
const line = rawLine.trim();
|
|
@@ -181,7 +181,7 @@ export async function getManagedEnvNames(cwd = process.cwd(), target = 'ecs') {
|
|
|
181
181
|
}
|
|
182
182
|
// NODE_ENV is injected only when the worker renders (the generator
|
|
183
183
|
// scopes it to worker trees): on workerless trees it is a legitimate
|
|
184
|
-
// custom key and must not auto-skip
|
|
184
|
+
// custom key and must not auto-skip. Unreadable dirs keep
|
|
185
185
|
// the base set above (fail-closed; the TF precondition backstops
|
|
186
186
|
// real collisions there).
|
|
187
187
|
if (!tfFiles.includes('worker.tf')) names.delete('NODE_ENV');
|
|
@@ -252,9 +252,9 @@ function vaultPayloadShape(parsed) {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
// Validates a GetSecretValue response into the managed JSON object.
|
|
255
|
-
// Refuses binary payloads (
|
|
255
|
+
// Refuses binary payloads (They read as "empty" and a push
|
|
256
256
|
// would full-replace them away without the removal confirm) and
|
|
257
|
-
// non-object/non-string payloads (
|
|
257
|
+
// non-object/non-string payloads (Phantom `0,1` removals,
|
|
258
258
|
// garbage pull keys, TypeError crashes). A response carrying neither
|
|
259
259
|
// field means an empty/new vault — live AWS never returns that shape
|
|
260
260
|
// for a valued secret.
|
|
@@ -289,7 +289,7 @@ function vaultPayloadObject(resp, secretId) {
|
|
|
289
289
|
const ATTEMPTED_KEY_RE = /^\s*([^=:#\s][^=:]*?)\s*[=:]/;
|
|
290
290
|
|
|
291
291
|
// Finds .env input lines dotenv silently dropped plus duplicate keys
|
|
292
|
-
|
|
292
|
+
//. Multiline double-quoted values span lines — continuation
|
|
293
293
|
// lines are value text, not dropped lines. Pure and unit-tested via
|
|
294
294
|
// push output.
|
|
295
295
|
function analyzeEnvLines(envContent, parsedSecrets) {
|
|
@@ -363,7 +363,7 @@ async function handleSecretsCatch({
|
|
|
363
363
|
} else if (handleAuthErrorBranch(error, s, opts)) {
|
|
364
364
|
return;
|
|
365
365
|
}
|
|
366
|
-
//
|
|
366
|
+
// Failures after the vault write (keys file, ECS restart)
|
|
367
367
|
// must report the vault as updated with the recovery step — a bare
|
|
368
368
|
// "Failed to push" lies about what succeeded.
|
|
369
369
|
const postVaultHints = {
|
|
@@ -415,7 +415,7 @@ export async function pushSecrets(envFilePath, projectName, options = {}) {
|
|
|
415
415
|
}
|
|
416
416
|
|
|
417
417
|
async function pushSecretsMain(envFilePath, projectName, options = {}) {
|
|
418
|
-
//
|
|
418
|
+
// Push is read-modify-full-replace — serialize local
|
|
419
419
|
// concurrent pushes like every other mutating family (the re-read
|
|
420
420
|
// before UpdateSecret below covers cross-machine second writers).
|
|
421
421
|
return withProjectLock(process.cwd(), () => pushSecretsInner(envFilePath, projectName, options));
|
|
@@ -456,14 +456,14 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
456
456
|
resolvedFilePath = '.env';
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
//
|
|
459
|
+
// Shared helper — the terraform project name outranks the
|
|
460
460
|
// directory basename (a renamed directory must not aim at a phantom).
|
|
461
461
|
const resolvedProjectName = resolveSecretsProject(explicitProjectName);
|
|
462
462
|
|
|
463
463
|
const s = spinner();
|
|
464
464
|
s.start(truncateSpinnerText(`Reading ${envFilePath} and pushing to AWS Secrets Manager...`));
|
|
465
465
|
|
|
466
|
-
//
|
|
466
|
+
// Write progress for the catch below — names the post-vault
|
|
467
467
|
// follow-up step when one fails, so the report says the vault is
|
|
468
468
|
// updated instead of misreporting a failed push.
|
|
469
469
|
let postVaultStep = null;
|
|
@@ -518,7 +518,7 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
518
518
|
|
|
519
519
|
const parsedSecrets = dotenv.parse(envContent);
|
|
520
520
|
|
|
521
|
-
//
|
|
521
|
+
// Dotenv silently drops lines it cannot parse (and
|
|
522
522
|
// last-wins duplicates) — name them so the success count below
|
|
523
523
|
// reconciles with the file. Runs before the empty early-return
|
|
524
524
|
// so an all-dropped file explains itself.
|
|
@@ -540,7 +540,7 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
540
540
|
return;
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
// Pre-write guards
|
|
543
|
+
// Pre-write guards: colliding keys are auto-skipped
|
|
544
544
|
// on ECS — pushing them can only brick the deploy, so excluding
|
|
545
545
|
// them with a loud notice beats refusing and demanding a hand
|
|
546
546
|
// edit. Local-dev wiring values warn. Everything surfaces before
|
|
@@ -612,18 +612,18 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
|
|
615
|
-
//
|
|
615
|
+
// Push is full-replace, so vault keys absent from .env are
|
|
616
616
|
// deleted by the update below. Name every victim before writing;
|
|
617
617
|
// interactive runs confirm first, headless proceeds loudly.
|
|
618
618
|
// Skipped keys are present in .env, so they never land here — their
|
|
619
619
|
// exclusion from the vault write is covered by the skip notice
|
|
620
620
|
// above, not by this confirm.
|
|
621
621
|
const removed = (existingKeys ?? []).filter((key) => !Object.hasOwn(parsedSecrets, key));
|
|
622
|
-
//
|
|
622
|
+
// Skipped keys are present in .env (so they never land in
|
|
623
623
|
// `removed`) but excluded from the vault write — a stale vault
|
|
624
624
|
// value for a skipped key is wiped by the full-replace update.
|
|
625
625
|
// Name every such victim loudly. The skip notice above is the
|
|
626
|
-
// acknowledgment, so unlike
|
|
626
|
+
// acknowledgment, so unlike true removals these never confirm.
|
|
627
627
|
const staleSkipped = skipped.filter((key) => (existingKeys ?? []).includes(key));
|
|
628
628
|
if (staleSkipped.length > 0) {
|
|
629
629
|
console.log(color.yellow(`⚠️ ${staleSkipped.length} skipped ${staleSkipped.length === 1 ? 'key' : 'keys'} still ${staleSkipped.length === 1 ? 'has' : 'have'} a stale vault value that this push deletes (no longer pushed):`));
|
|
@@ -656,7 +656,7 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
656
656
|
s.start(truncateSpinnerText(`Reading ${envFilePath} and pushing to AWS Secrets Manager...`));
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
-
//
|
|
659
|
+
// The confirm above can wait unboundedly — re-read the
|
|
660
660
|
// vault immediately before the full-replace write and abort when
|
|
661
661
|
// a second writer moved the payload since the first read.
|
|
662
662
|
let rereadSecretString = null;
|
|
@@ -690,7 +690,7 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
690
690
|
const keys = Object.keys(pushableSecrets);
|
|
691
691
|
const keysFilePath = path.join(process.cwd(), 'terraform', 'secret_keys.json');
|
|
692
692
|
|
|
693
|
-
//
|
|
693
|
+
// Skip the write when the file is already byte-identical
|
|
694
694
|
// so unchanged pushes don't dirty `git status`.
|
|
695
695
|
const nextKeysContent = JSON.stringify(keys, null, 2);
|
|
696
696
|
let keysUnchanged = false;
|
|
@@ -1041,7 +1041,7 @@ async function auditSecretsMain(envFilePath, projectName, options = {}) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
|
-
//
|
|
1044
|
+
// Flag both limbs — keys colliding with Grada-managed
|
|
1045
1045
|
// environment names (fatal on ECS, shadowing on Lambda) and
|
|
1046
1046
|
// wiring-like values that look like local-dev placeholders.
|
|
1047
1047
|
const auditTarget = readTerraformComputeTarget(process.cwd());
|
package/src/commands/status.js
CHANGED
|
@@ -453,7 +453,7 @@ async function runStatusMain(input = {}) {
|
|
|
453
453
|
return runStaticStatus({ ...options, cwd, region, projectName });
|
|
454
454
|
}
|
|
455
455
|
const resourceSuffix = readResourceSuffix(cwd);
|
|
456
|
-
// Workspace-namespaced resources
|
|
456
|
+
// Workspace-namespaced resources: --workspace (or the local
|
|
457
457
|
// .terraform/environment) targets a preview stack like rollback and db
|
|
458
458
|
// do. Explicit flags/env keep winning; telemetry keeps the raw name.
|
|
459
459
|
const namespacedProject = resolveNamespacedProject(projectName, options, cwd);
|
|
@@ -502,9 +502,9 @@ async function runStatusMain(input = {}) {
|
|
|
502
502
|
return;
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
// Namespaced stem
|
|
505
|
+
// Namespaced stem: the raw project prefix merged prod
|
|
506
506
|
// + preview alarms into one verdict and could auto-diagnose the
|
|
507
|
-
// wrong cluster. Paired with workspace-aware alarm names
|
|
507
|
+
// wrong cluster. Paired with workspace-aware alarm names.
|
|
508
508
|
const alarmsResp = await cloudWatchClient.send(new DescribeAlarmsCommand({ AlarmNamePrefix: `${namespacedProject}${resourceSuffix}`, MaxRecords: 100 }));
|
|
509
509
|
const rawAlarms = [...(alarmsResp.MetricAlarms || []), ...(alarmsResp.CompositeAlarms || [])];
|
|
510
510
|
|
package/src/commands/wake.js
CHANGED
|
@@ -221,7 +221,7 @@ async function runWakeMain(input = {}) {
|
|
|
221
221
|
// both must reach the main flow, never the already-awake
|
|
222
222
|
// skip. Every other status (available, starting, …) is
|
|
223
223
|
// started or self-resolving, so there is nothing for wake
|
|
224
|
-
// to do
|
|
224
|
+
// to do.
|
|
225
225
|
const dbAwake = !foundDb || (foundDb.status !== 'stopped' && foundDb.status !== 'stopping');
|
|
226
226
|
if (servicesAwake && dbAwake) {
|
|
227
227
|
return reportSleepWakeSkip({
|
|
@@ -258,7 +258,7 @@ async function runWakeMain(input = {}) {
|
|
|
258
258
|
// A transitional database (stopping/starting/…) can neither
|
|
259
259
|
// start nor serve: settle first (mirroring destroy), then
|
|
260
260
|
// start when it lands on `stopped`. Never restore ECS +
|
|
261
|
-
// report success over an unsettled database
|
|
261
|
+
// report success over an unsettled database.
|
|
262
262
|
if (dbTarget && dbTarget.status !== 'stopped' && dbTarget.status !== 'available') {
|
|
263
263
|
const transitional = dbTarget.status;
|
|
264
264
|
const isCluster = dbTarget.kind === 'cluster';
|
package/src/utils/addons.js
CHANGED
|
@@ -83,7 +83,7 @@ export const ADDON_REGISTRY = {
|
|
|
83
83
|
export const ADDON_TARGET_POLICY = {
|
|
84
84
|
// Static trees have no task role or VPC: every one of these renders
|
|
85
85
|
// a dangling aws_iam_role.task_role / aws_vpc reference on static
|
|
86
|
-
//
|
|
86
|
+
// Refuse fast instead of emitting unplannable TF.
|
|
87
87
|
'storage:s3': { ecs: 'allow', lambda: 'allow', static: 'refuse' },
|
|
88
88
|
'db:dynamodb': { ecs: 'allow', lambda: 'allow', static: 'refuse' },
|
|
89
89
|
'db:redis': { ecs: 'allow', lambda: 'allow', static: 'refuse' },
|
package/src/utils/backup.js
CHANGED
|
@@ -32,7 +32,7 @@ function collectManifestFiles(targetDir) {
|
|
|
32
32
|
// Preview/teardown/drift carry project names + role ARNs and invite
|
|
33
33
|
// hand edits like deploy.yml — manifest them so re-init refuses
|
|
34
34
|
// dirty trees and backs them up instead of silently overwriting or
|
|
35
|
-
// leaving them stale
|
|
35
|
+
// leaving them stale.
|
|
36
36
|
for (const rel of ['Dockerfile', 'preview.yml', 'teardown.yml', 'drift.yml', 'plan.yml'].map((name) => (
|
|
37
37
|
name === 'Dockerfile' ? name : path.join('.github', 'workflows', name)
|
|
38
38
|
))) {
|