Repository navigation
feat(ec2): key instance-type offerings by AZ ID (#893) - #897
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
DescribeInstanceTypeOfferings now answers LocationType=availability-zone-id, and the unmodelled-LocationType refusal narrows to outpost alone. This reverses a recorded decision by making its premise false rather than by relaxing it: ec2UnmodelledLocationTypeError gave the reason as substrate "reports AZ IDs from DescribeAvailabilityZones but does not key offerings by them", so offerings now key by AZ ID, taken from ec2SeededZones -- the single producer of a zone's name and ID and what DescribeAvailabilityZones renders from. The availability-zone arm reads the same producer, so the two forms of a zone cannot drift. The doc comment moves with the behaviour in the same commit. outpost stays refused for the untouched half of the original reasoning: its location is an Outpost ARN and substrate seeds no Outpost. Closes #893.
scttfrdmn
force-pushed
the
feat/ec2-offerings-availability-zone-id
branch
from
September 15, 2026 22:15
bc8a54f to
cd1c8a5
Compare
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.
DescribeInstanceTypeOfferingsnow answersLocationType=availability-zone-id, and theunmodelled-
LocationTyperefusal narrows tooutpostalone.Closes #893.
The recorded decision this reverses, and why the reversal is honest
The refusal was deliberate, not an oversight, and
ec2UnmodelledLocationTypeErrorcarried itsreason:
That argument holds exactly as written. So this PR does not relax it — it makes the first clause
false. Offerings are now keyed by AZ ID, and the second clause never applies because the response
carries real IDs rather than names mislabelled as IDs. The doc comment changed in the same
commit as the behaviour, so nothing is left describing a refusal that no longer happens; a stale
rationale is the defect class this project spends releases removing.
outpoststays refused for the half of that reasoning nothing changed: its location is an OutpostARN, substrate seeds no Outpost, and there is no ARN it could report. The refusal message now
offers
availability-zone-idamong the remedies.What AWS publishes
Verified against the API reference (both pages returned real content; nothing here is from
recollection):
API_DescribeInstanceTypeOfferings—
LocationTypeValid Values:region | availability-zone | availability-zone-id | outpost,and per-value: "
availability-zone-id- The AZ ID. When you specify a location filter, it mustbe an AZ ID for the current Region", "
outpost- The Outpost ARN. When you specify a locationfilter, it must be an Outpost ARN for the current Region".
API_InstanceTypeOffering—
locationis "The identifier for the location. This depends on the location type";locationTypeValid Values are the same four.
So the per-item
locationTypeechoingavailability-zone-idwhilelocationcarries the ID isthe shape AWS documents, and that mismatch is what the issue was about.
Implementation
describeInstanceTypeOfferingscollectingZoneIDfromec2SeededZones(reqCtx.Region)— the single producer of a zone's name and ID, and whatDescribeAvailabilityZonesrenders from. Not a reimplementation ofazRegionAbbrev, sous-east-1a↔use1-az1cannot drift between the two operations.availability-zonearm was switched onto the same producer (it enumeratedec2SeededAZSuffixesdirectly). Behaviour-identical today, and deliberate: one producer means azone the seed later reports differently — an unavailable zone, a fourth zone — cannot leave the
two arms disagreeing about which locations exist. Recorded in the handler comment rather than
left to the diff.
ec2UnmodelledLocationTypeErrornarrowed tooutpost, doc comment rewritten to the remainingreason and to record that EC2: DescribeInstanceTypeOfferings should model LocationType=availability-zone-id #893 reversed the other half.
locationfilter needed no change, and this was verified rather than assumed — itcompares against whatever the
locationsslice holds, souse1-az1selects andus-east-1aselects nothing. Both directions are asserted.
The caveat a consumer needs
Substrate maps zone
ato-az1in every account, because a deterministic emulator cannot hold aper-account secret, whereas AWS "independently map[s] Availability Zones to codes for each AWS
account". A consumer whose invariant is that AZ names are per-account randomised is correct against
AWS and will find substrate more forgiving. Read the ID out of
DescribeAvailabilityZones; do nothardcode
use1-az1— a test asserting the literal pairing passes here and asserts nothing about areal account.
The tests are written to that rule: the new subtest builds a name→ID map from
DescribeAvailabilityZonesand asserts the offerings'locationagainst it, with no AZ-ID literalanywhere.
docs/services.mdsays the same thing at the point of use.Two adjacent gaps, recorded and deliberately not touched
MaxResultsandNextTokenare unimplemented on this operation, although the handler's owndoc comment lists them among the reference's parameters — so a paginating caller gets the whole
set on every call with no
nextToken. AWS specifiesMaxResultsas min 5 / max 1000 and anextTokenresponse element.availability-zone-idis accepted-but-inert as a filter name on five other EC2 describes(
emulator/ec2_filters.go, e.g.ec2SpotPriceFilterSpec'sacceptedlist and the comment aboveit). The same
ec2SeededZonespairing now makes those implementable, which is a strictly largerfollow-up.
Verification
Run from the repo root, all green:
TestEC2_DescribeInstanceTypeOfferings_LocationType— 7 subtests, all pass, including the two newones.
npm --prefix docs run buildwas skipped:docs/node_modulesis git-ignored and absent in afresh worktree, so it exits 127; CI covers the docs build.
One test changed rather than being added: the
availability-zone-id/outpostrefusal loop is nowoutpostonly. That test was passing on the old refusal, and its inversion is the reversal thisPR records — not a relaxed assertion.