@grada-run/grada 0.49.8 → 0.49.9
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
CHANGED
package/src/commands/apply.js
CHANGED
|
@@ -406,6 +406,18 @@ function preflightSecretEnvCollisions({ targetDir }) {
|
|
|
406
406
|
return { kind: 'collision', keys: collisions };
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
+
// Picks the live AWSCURRENT version id out of a DescribeSecret
|
|
410
|
+
// response — null when none is staged current (a missing or
|
|
411
|
+
// stageless map means there is nothing safe to adopt).
|
|
412
|
+
function currentLiveVersionId(described) {
|
|
413
|
+
const stages = described?.VersionIdsToStages;
|
|
414
|
+
if (!stages || typeof stages !== 'object') return null;
|
|
415
|
+
for (const [versionId, versionStages] of Object.entries(stages)) {
|
|
416
|
+
if (Array.isArray(versionStages) && versionStages.includes('AWSCURRENT')) return versionId;
|
|
417
|
+
}
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
|
|
409
421
|
export async function applyStack(input = {}) {
|
|
410
422
|
setActiveCommandName('apply');
|
|
411
423
|
try {
|
|
@@ -974,6 +986,7 @@ async function applyStackMain(input = {}) {
|
|
|
974
986
|
if (!isCancel(choice) && (choice === 'restore' || choice === 'force-delete')) method = choice;
|
|
975
987
|
}
|
|
976
988
|
if (method) {
|
|
989
|
+
let versionAdopted = null;
|
|
977
990
|
try {
|
|
978
991
|
const targetRegion = detectedConfig.region || process.env.AWS_REGION || 'us-east-2';
|
|
979
992
|
const client = resolveClient(options.secretsClient, SecretsManagerClient, { region: targetRegion });
|
|
@@ -986,6 +999,15 @@ async function applyStackMain(input = {}) {
|
|
|
986
999
|
// Argv-spawned (no shell), so the count index
|
|
987
1000
|
// needs no quoting — unlike the printed runbook.
|
|
988
1001
|
await runTerraform(['import', 'aws_secretsmanager_secret.app_secrets[0]', described.ARN], tfDir, null, `Importing ${secretName}`);
|
|
1002
|
+
// Adopt the live current version too: without
|
|
1003
|
+
// it the retry recreates the placeholder
|
|
1004
|
+
// version over the restored real values
|
|
1005
|
+
// (ignore_changes never stops creation).
|
|
1006
|
+
const liveVersion = currentLiveVersionId(described);
|
|
1007
|
+
versionAdopted = liveVersion !== null;
|
|
1008
|
+
if (liveVersion) {
|
|
1009
|
+
await runTerraform(['import', 'aws_secretsmanager_secret_version.app_secrets_initial[0]', `${described.ARN}|${liveVersion}`], tfDir, null, `Importing ${secretName} live values`);
|
|
1010
|
+
}
|
|
989
1011
|
} else {
|
|
990
1012
|
await client.send(new DeleteSecretCommand({ SecretId: secretName, ForceDeleteWithoutRecovery: true }));
|
|
991
1013
|
}
|
|
@@ -993,9 +1015,18 @@ async function applyStackMain(input = {}) {
|
|
|
993
1015
|
secretRecoveryError = error;
|
|
994
1016
|
}
|
|
995
1017
|
if (secretRecoveryError === null) {
|
|
996
|
-
trackEvent('secret_deletion_recovered', {
|
|
1018
|
+
trackEvent('secret_deletion_recovered', {
|
|
1019
|
+
projectName: actualProjectName,
|
|
1020
|
+
method,
|
|
1021
|
+
...(method === 'restore' ? { adopted: versionAdopted === true } : {}),
|
|
1022
|
+
});
|
|
997
1023
|
if (method === 'restore') {
|
|
998
|
-
|
|
1024
|
+
if (versionAdopted) {
|
|
1025
|
+
log.message(color.cyan('Restored the secret vault and adopted its live values — retrying apply...'));
|
|
1026
|
+
} else {
|
|
1027
|
+
log.message(color.cyan('Restored the secret vault and imported it — retrying apply...'));
|
|
1028
|
+
log.message(color.yellow(' Live values could not be adopted: run secrets audit after apply and re-push if they look wrong.'));
|
|
1029
|
+
}
|
|
999
1030
|
} else {
|
|
1000
1031
|
log.message(color.cyan('Force-deleted the secret vault — retrying apply...'));
|
|
1001
1032
|
log.message(color.dim(' Re-push your secrets after apply (secrets push): the vault is recreated empty.'));
|
|
@@ -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
|
|
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
|
|
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.',
|
|
166
166
|
},
|
|
167
167
|
};
|
|
168
168
|
|