Issue #594 - Added logic to inspect nested stacks for the API ID if it is not found in the main stacks (split-stacks support)#652
Conversation
first pass adding extra lookups
…ted stacks if it is not found in the main stack
|
Nice! |
…th of resources the nested stack with the API could wind up in a later page.
|
+1 |
|
@AlexHladin - review please |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThe plugin adds caching infrastructure and enhances API ID discovery to support nested CloudFormation stacks. A ChangesAppSync API ID Caching and Discovery
Sequence DiagramsequenceDiagram
participant Plugin
participant Cache
participant CloudFormation
participant NestedStack
Plugin->>Cache: Check if apiId cached
alt Cache hit
Cache-->>Plugin: Return cached apiId
else Cache miss
Plugin->>CloudFormation: Compute API logical ID
Plugin->>CloudFormation: describeStackResources (main stack)
CloudFormation-->>Plugin: Check for API resource
alt API found in main stack
Plugin->>Cache: Store apiId
Cache-->>Plugin: apiId cached
Cache-->>Plugin: Return apiId
else API not in main stack
Plugin->>CloudFormation: listStackResources (paginate)
CloudFormation-->>Plugin: Stack resource summaries
Plugin->>CloudFormation: describeStacks (nested stack)
CloudFormation-->>Plugin: Stack with outputs
NestedStack->>Plugin: Extract API ID from stackOutputKey
Plugin->>Cache: Store apiId
Cache-->>Plugin: apiId cached
Cache-->>Plugin: Return apiId
end
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/index.ts (1)
389-468: ⚡ Quick winAdd focused tests for the new lookup branches.
src/__tests__/commands.test.ts:313-374still only covers the direct main-stack lookup, so regressions in nested-stack resolution,listStackResourcespagination, or the new memoization path will be easy to miss.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/index.ts` around lines 389 - 468, Tests need to be added to cover nested-stack resolution, listStackResources pagination, and the memoization path around this.cachedValues.apiId so regressions don't slip through; add focused unit tests that (1) simulate provider.request responses where the main stack lacks the Api resource but listStackResources returns multiple pages with nested AWS::CloudFormation::Stack entries and the ApiId is found in a nested stack's Outputs (exercise the describeStacks path and stackOutputKey lookup), (2) simulate pagination by returning NextToken on the first listStackResources call and the Api found only on a later page, and (3) verify that once this.cachedValues.apiId is set subsequent calls short-circuit and do not invoke provider.request again (memoization). Target the test file referenced (src/__tests__/commands.test.ts) and mock provider.request for the CloudFormation calls used in this code (describeStackResources, listStackResources, describeStacks) and assert correct behavior for apiId resolution and caching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/index.ts`:
- Around line 389-468: Tests need to be added to cover nested-stack resolution,
listStackResources pagination, and the memoization path around
this.cachedValues.apiId so regressions don't slip through; add focused unit
tests that (1) simulate provider.request responses where the main stack lacks
the Api resource but listStackResources returns multiple pages with nested
AWS::CloudFormation::Stack entries and the ApiId is found in a nested stack's
Outputs (exercise the describeStacks path and stackOutputKey lookup), (2)
simulate pagination by returning NextToken on the first listStackResources call
and the Api found only on a later page, and (3) verify that once
this.cachedValues.apiId is set subsequent calls short-circuit and do not invoke
provider.request again (memoization). Target the test file referenced
(src/__tests__/commands.test.ts) and mock provider.request for the
CloudFormation calls used in this code (describeStackResources,
listStackResources, describeStacks) and assert correct behavior for apiId
resolution and caching.
I took @tobinc's changes and refactored them to instead only look in nested cloudformation stacks to get the graphql api's id. This limits the stacks that will need to be investigated to only those that are part of the main stack.
Summary by CodeRabbit