Repository navigation
fix(sp): stop filtering Savings Plan recommendations on the endpoint region - #2182
Conversation
…region fetchRecommendationsForRegion passed the SP API endpoint region (us-east-1) as RecommendationParams.Region. The provider folds that into its include-region set, so every EC2 Instance Savings Plan recommended in another region was dropped. Region is no longer set for Savings Plans. Closes #2176 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gate verdict: APPROVE at 323d81eIndependent gate review (Opus), base Root cause confirmed against the pinned module ( Call-site reproduction (gate-only test, not committed): real
Regression surface checked
Tests / mutations
Non-blocking follow-up (OWNER decision): Local evidence is fixture-based (local HTTP stub), not a live AWS call; the author's dry-run against a real account is in the PR body. |
Closes #2176
Root cause
fetchRecommendationsForRegion(cmd/multi_service_helpers.go) setparams.Region = region. For Savings Plans the only "region" isspAPIRegion(us-east-1), the endpoint the account-level call is signed in. The provider adapter (applyRecommendationFilters, go providers/aws/service_client.go) foldsparams.Regioninto its include-region set, and EC2 Instance SP recs are region-scoped (EffectiveRegion=Details.Region), so everything outside us-east-1 was dropped. Cost Explorer's SP recommendation call is not region-scoped. The fix leavesRegionunset for Savings Plans; explicit--include-regions/--exclude-regionsstill apply through the existing filters.Evidence
Regression test
TestFetchRecommendationsForRegion_SavingsPlanDoesNotFilterOnEndpointRegion(cmd/savings_plan_purchase_test.go).expected: "" actual: "us-east-1".go test ./...passes;go vetclean. (make lintcould not run locally: golangci-lint is built with an older Go than go.mod requires; CI is authoritative.)Real data, dry run only, no
--regions, account via management account,--services savingsplans --include-sp-types EC2Instance --term 1 --payment no-upfront --rec-lookback-period 30d --coverage 100:[1/1] Region: us-east-1/ "No recommendations found" for all four types.Found 3 recommendations, savings $342.39/mo (eu-west-2 m5 $226.84, eu-central-2 m5 $77.77, eu-west-2 m5a $37.77), matchingaws ce get-savings-plans-purchase-recommendationfor the same parameters.No library change needed. No purchase flags were used.
🤖 Generated with Claude Code
Summary by CodeRabbit