Skip to content

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

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

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