Skip to content

refactor(aws): consolidate 5 near-identical RI term parsers (drift already started) #34

Closed

Description

@cristim

Duplication audit (owner-requested) found LeanerCloud/cloud-commitments-cli#1207 added 5 near-identical term-parsing helpers across the service clients, and DRIFT HAS ALREADY BEGUN: requiredMonthsForTerm (opensearch + redshift, identical bar the service name in the error), getDurationString (elasticache + rds, identical), getDurationStringForAPI (memorydb, a variant that ALSO accepts "12"/"36"). All validate the same 1yr/1/3yr/3 domain on a MONEY path (RI term -> offering purchase), so divergence risks mispriced/mistermed purchases.

Consolidate into a shared ParseTermMonths(term, service string) (int, error) + duration-string formatter in providers/aws/internal/purchasecfg (alongside LeanerCloud/cloud-commitments-cli#1390's ResolveTag) or a sibling terms pkg. Keep each caller's fail-loud behavior (LeanerCloud/cloud-commitments-cli#1207); reconcile the memorydb "12"/"36" variant deliberately (decide if numeric forms are valid everywhere). All existing term tests must pass unchanged.

Activity

  1. cristim commented on Oct 7, 2026

    @cristim
    MemberAuthor

    Claimed by worker 4 (shard rank 24). Starting consolidation of the five RI term parsers into a shared helper in providers/aws, per the issue's fix direction.

  2. added a commit that references this issue on Oct 7, 2026
    f5f37d6
  3. cristim commented on Oct 7, 2026

    @cristim
    MemberAuthor

    Resolved by PR #273, merged normally as 5599b24 from independently reviewed head 60868b6. All nine owned source/test files match the verified head byte-for-byte. Shared term parsing, six service consumers, MemoryDB legacy aliases and complete diagnostic, and exported duration constants are preserved. Local Go 1.26.6 builds and the full AWS race suite passed; pre-merge CI is green. Actual merge-commit CI is being watched. Fixture and mock evidence was used; no live cloud purchase was exercised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions