@intentius/chant-lexicon-aws 0.18.25 → 0.18.27

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/src/plugin.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "module";
2
2
  import { detectTemplate } from "./detect";
3
- import type { LexiconPlugin, IntrinsicDef, ResourceMetadata, ExportedTemplate, ResourceSelector, InitTemplateSet } from "@intentius/chant/lexicon";
3
+ import type { LexiconPlugin, IntrinsicDef, ResourceMetadata, ExportedTemplate, ResourceSelector, InitTemplateSet, StackStatusObservation } from "@intentius/chant/lexicon";
4
4
  const require = createRequire(import.meta.url);
5
5
  import type { LintRule } from "@intentius/chant/lint/rule";
6
6
  import type { TemplateParser } from "@intentius/chant/import/parser";
@@ -577,6 +577,34 @@ aws cloudformation wait stack-update-complete --stack-name my-app-prod`,
577
577
  return resources;
578
578
  },
579
579
 
580
+ async describeStackStatus(options: { environment: string; stack: string }): Promise<StackStatusObservation | null> {
581
+ const { getRuntime } = await import("@intentius/chant/runtime-adapter");
582
+ const rt = getRuntime();
583
+
584
+ const result = await rt.spawn(applyAwsEndpointArgv([
585
+ "aws", "cloudformation", "describe-stacks",
586
+ "--stack-name", options.stack,
587
+ "--output", "json",
588
+ ], process.env.AWS_ENDPOINT_URL));
589
+
590
+ if (result.exitCode !== 0) {
591
+ // A stack that doesn't exist yet is the pre-first-apply state (absent, not
592
+ // an error). Any other failure is indeterminate → null, so the caller
593
+ // degrades rather than reporting a healthy stack as gone.
594
+ if (stackDoesNotExist(result.stderr)) return { stack: options.stack, present: false };
595
+ return null;
596
+ }
597
+
598
+ const parsed = JSON.parse(result.stdout) as { Stacks?: Array<{ StackStatus?: string }> };
599
+ const status = parsed.Stacks?.[0]?.StackStatus;
600
+ if (!status) return { stack: options.stack, present: false };
601
+ // Healthy = a terminal *success* apply. Rollback/failed/in-progress/delete
602
+ // states are present-but-not-healthy, so a renderer can distinguish
603
+ // deployed-green from mid-deploy or broken.
604
+ const healthy = /^(CREATE|UPDATE|IMPORT)_COMPLETE$/.test(status);
605
+ return { stack: options.stack, present: true, status, healthy };
606
+ },
607
+
580
608
  async exportResources(options: {
581
609
  environment: string;
582
610
  stack?: string;