Skip to content

lifecycle snapshot observes every stack against the ambient region #1261

Closed

Description

@lex00

What happens

On a multi-region project, chant lifecycle snapshot <env> only captures the stacks that live in the ambient region. Every other stack fails with:

aws: no valid resources or artifacts returned

Reproduced against a 4-stack, 3-region estate (us-east-1 ×2, us-west-1, us-west-2) on the Floci emulator with AWS_DEFAULT_REGION=us-east-1:

ec2-multiregion-EC2-ks84v1fh12-us-east-1: Snapshot saved to chant/lifecycle (aws(17))
error: aws: no valid resources or artifacts returned
error: aws: no valid resources or artifacts returned
ec2-multiregion-QARoles-us-east-1: Snapshot saved to chant/lifecycle (aws(4))

Two of four stacks recorded. chant lifecycle show then reports a partial estate, and a subsequent diff would read the missing stacks as absent rather than unobserved.

Cause

config.stacks[].region is dropped on the way to the plugin.

  • resolveStackTargets (cli/handlers/lifecycle.ts) maps config.stacks to { stack: s.name, root: resolve(s.src) }, discarding s.region.
  • takeSnapshot (lifecycle/snapshot.ts) has no region in its options and calls plugin.describeResources({ environment, buildOutput, entityNames, entities, stack }).
  • The AWS plugin already supports it — describeResources, exportResources and listArtifacts all take region?: string and build regionArgs, with the comment "Multi-region estates: target this stack's region, not the ambient one." It simply never receives one.

So the plugin falls back to the ambient region and describe-stack-resources finds nothing for out-of-region stacks.

chant search --live is unaffected because cli/handlers/search.ts maps config.stacks to { name, region, src } and passes regions through. The same estate returns all six instances across all three regions via search --live.

Suggested fix

Thread the declared region the way search already does:

  1. StackTarget gains region?: string, and resolveStackTargets carries s.region.
  2. takeSnapshot's options gain region?: string, forwarded to describeResources and listArtifacts.
  3. The snapshot call site passes { stack: target.stack, region: target.region }.

Also worth checking

runLifecycleDiffLive is reached from the same resolveStackTargets loop and is passed only stack: target.stack, so lifecycle diff is likely the same shape. observeResources already accepts stacks: Array<{ name, region, src }>, so the plumbing exists there too.

Impact

Any multi-region project. The snapshot is silently partial: it exits having written some stacks, so the failure reads as a per-stack quirk rather than a systematic region miss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions