Skip to content

fix(aws/savingsplans): add USD currency + region filter and deterministic sort to findOfferingID #1066

Closed

Description

@cristim

Problem

findOfferingID in providers/aws/services/savingsplans/client.go calls
DescribeSavingsPlansOfferings without narrowing by currency or region, and
then returns the first result from an unordered API response. AWS does not
guarantee ordering of DescribeSavingsPlansOfferings results, so when
multiple offerings match (e.g. USD vs CNY, or global vs region-scoped) the
chosen offering ID is nondeterministic and may be non-USD or off-target.

Source: finding 08-L1 (SP portion) from the code-review series (report 08).

Evidence

DescribeSavingsPlansOfferingsInput already accepts:

  • Currencies []types.CurrencyCode — lets us pin to USD server-side.
  • Filters []types.SavingsPlanOfferingFilterElement with
    SavingsPlanOfferingFilterAttributeRegion — lets us pin to the client
    region for EC2Instance SPs (Compute/SageMaker/Database SPs are
    region-agnostic; filter is omitted for them).

Currently neither filter is set, so any currency or region variant can
land in position 0 of the response.

Fix

  1. Set Currencies: []types.CurrencyCode{types.CurrencyCodeUsd} on the
    input before calling DescribeSavingsPlansOfferings.
  2. For EC2Instance SPs, add a region filter element (the only SP type that
    has region-specific offerings). Compute, SageMaker, and Database SPs are
    global.
  3. Sort SearchResults by OfferingId (lexicographically) before returning
    the first match, so the tie-break is stable if multiple offerings still
    match after filtering.

Files

providers/aws/services/savingsplans/client.go,
providers/aws/services/savingsplans/client_test.go

PR

Folds into #1039 (fix/aws-sp-pagination), which already modifies this file.

Activity

  1. added 2 commits that reference this issue on Jun 7, 2026
    9d292dc
    b7012e7
  2. added
    pr-createdA PR has been opened for this issue (dedup guard for the auto-PR loop)
    pr-mergedThe PR for this issue has been merged
    on Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpr-createdA PR has been opened for this issue (dedup guard for the auto-PR loop)pr-mergedThe PR for this issue has been mergedpriority/p2Backlog-worthyseverity/lowMinor harmtriagedItem has been triagedurgency/this-quarterWithin the quarter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions