Repository navigation
fix(aws-savingsplans): apply offering filters, validate commitment/tags, paginate describes - #1538
Open
Satyam-Trivedi-ZS wants to merge 1 commit into
Conversation
…gs, paginate describes - DescribeSavingsPlansOfferings now applies productType, filters[] (region / instanceFamily, matched against the offering properties) and the other documented request lists (paymentOptions, durations, currencies, descriptions, serviceCodes, usageTypes, operations), and returns offering properties. - CreateSavingsPlan rejects a commitment outside [0.001, 1000000] or with more than five decimal places (ValidationException). - TagResource / CreateSavingsPlan reject an empty or >128-char tag key and a >256-char value (ValidationException). - DescribeSavingsPlans / DescribeSavingsPlansOfferings honor maxResults / nextToken with offset tokens; bad tokens or out-of-range maxResults are ValidationException. Part of stackshy#1515 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #1515. This closes five of the seven open AWS Savings Plans parity gaps: DescribeSavingsPlansOfferings
productTypeandfilters, commitment range validation, pagination for DescribeSavingsPlans and DescribeSavingsPlansOfferings, and empty tag keys. One item is left as unverifiable and one is skipped. Reasons for both are below.productTypedecoded but never appliedfilters(instanceFamily / region) decoded but never appliedpaymentOptions,durations,currencies,descriptions,serviceCodes,usageTypes,operations) were not decoded at all, so they are now applied too.maxResults/nextTokenignoredclientTokenreused with different params returns the originaltags)server/aws/costexplorer), but it only serves GetCostAndUsage, GetCostForecast, GetDimensionValues and GetTags. Coverage and utilization need covered-vs-on-demand usage and amortization across services. That is a separate cross-service feature (the "billing-parity step 3" mentioned inhandler.go), and adding it would mean inventing numbers. The store already exposescost.Commitmentsfor when that handler lands.Changes
All changes are in
server/aws/savingsplans/. Savings Plans has no portable driver or provider package; its state lives in the handler-ownedstore(see the package doc). So the business rules went into the store, validation and filter files, and the handler only decodes and encodes.offerings.go(new):offeringFiltercoversofferingIds,planTypes,paymentOptions,durations,currencies,descriptions,serviceCodes,usageTypes,operations,productTypeandfilters[]. Dimensions are ANDed together; values inside one list are ORed. Thefilters[]names (region,instanceFamily) are the same enum asSavingsPlanOfferingPropertyKey, so an offering matches a filter when it has that property with one of the requested values. Offerings that span regions (Compute, SageMaker) have no region or instanceFamily property, so they don't match those filters.properties. The seeded EC2Instance offering reportsregion=<serve region>andinstanceFamily=m5, as in the realSavingsPlanOffering.propertiesfield.validation.go(new):validateCommitmentrejects with ValidationException anything outside [0.001, 1000000], NaN/Inf, or more than 5 decimal places.validateTagsrejects a key that is empty or longer than 128 characters, or a value longer than 256 characters, with ValidationException.paginateis an offset-token pager. It reuseswire.EncodeOffset/DecodeOffset, whose base64 tokens fit the documented^[A-Za-z0-9/=\+]+$pattern. An omittedmaxResultsreturns everything, as before. A negative value or one above 1000 is a ValidationException, and so is an undecodablenextToken.nextTokenis left out on the last page ("null when there are no more results").handler.go: describeSavingsPlans and describeOfferings now paginate. describeOfferings builds the filter and callsstore.describeOfferings.store.go: create/tag call the validators. Offerings carry a region.ListActivenow preallocates its slice, which clears the package's one pre-existingpreallocfinding; its behavior is unchanged.docs/coveragedoes not change. There is no new persisted state: the offering catalog is static and reseeded atNew.AWS docs
region | instanceFamily): https://docs.aws.amazon.com/savingsplans/latest/APIReference/API_SavingsPlanOfferingFilterElement.htmlsavingsplans/2019-06-28/service-2.jsonmodel (MaxResultsmin 1 / max 1000 for DescribeSavingsPlans,PageSizemin 0 / max 1000 for offerings, theSavingsPlanOfferingFilterAttributeenum, theSavingsPlanOffering.propertiesshape).Provider Coverage
Checklist
go test ./...)golangci-lint run --timeout=9m ./...): no new findings in the touched package. Repo-wide lint ondevelopmentalready reports findings in unrelated code (CI lint is report-only).golangci-lint run ./server/aws/savingsplans/...gives 0 issues on this branch, against 1 pre-existingpreallocondevelopment, which this PR fixes.cloudemu_test.go(n/a: wire-only service, covered by SDK tests)validation_test.go, store level)Test Plan
Unit tests (
server/aws/savingsplans/validation_test.go):Wire tests with the real aws-sdk-go-v2 savingsplans client (
server/aws/savingsplans/parity_sdk_test.go):All five SDK tests fail on
developmentand pass with this change. I checked this by restoring the original handler/store/types files.Also ran:
go build ./...go vet ./server/aws/savingsplans/go test -p 2 ./...(523 packages ok, 0 failures)golangci-lint run ./server/aws/savingsplans/...: 0 issues on this branch, against 1 pre-existing (preallocinListActive) ondevelopment. No new findings.Real-user test:
cloudemu serve -providers aws -aws-port 4605driven with AWS CLI v1 (botocore 1.42),--endpoint-url http://127.0.0.1:4605 --region us-east-1:Terraform has no Savings Plans resource to exercise here (and is not installed), so it was not run.
Related Issues
Part of #1515
🤖 Generated with Claude Code