You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EC2: DescribeInstanceTypeOfferings should model LocationType=availability-zone-id #893
DescribeInstanceTypeOfferings supports availability-zone and region but rejects availability-zone-id:
aws ec2 describe-instance-type-offerings --location-type availability-zone-id
# -> InvalidParameterValue: Value (availability-zone-id) for parameter LocationType is not modeled by substrate; use availability-zone or region
Consumer / why:sonde derives its offered grid at AZ-ID granularity — AZ names are per-account randomised and are never persisted or compared (its invariant I5). It queries --location-type availability-zone-id and reads Location as the AZ ID (e.g. use1-az1). Modeling this LocationType (with Location returning the AZ ID that corresponds to the AZ names already returned by DescribeAvailabilityZones) would let sonde's grid refresh run against substrate.
Confirmed, and this one is small — smaller than the issue's framing suggests, because the pairing it asks for already exists and is already the single source of truth for both forms.
The refusal is a recorded decision, not an oversight
describeInstanceTypeOfferings (emulator/ec2_plugin.go:5729) builds its location list in a four-arm switch at :5749-5760: availability-zone (the default) enumerates reqCtx.Region + suffix over ec2SeededAZSuffixes, region returns the one region, and availability-zone-id and outpost fall to ec2UnmodelledLocationTypeError (ec2_instancetypes.go:294). default falls to ec2InvalidLocationTypeError (:277), which exists because "DescribeInstanceTypeOfferings' reference gives the valid values as region | availability-zone | availability-zone-id | outpost, so a value outside that set is a bad request whether or not substrate models it" — i.e. the two errors are deliberately distinct, and the message naming substrate is deliberate too.
The reason recorded for refusing rather than aliasing is worth quoting, because it is the argument this issue has to answer, and it holds:
Substrate reports AZ IDs from DescribeAvailabilityZones but does not key offerings by them … Refusing is the honest answer: treating either as availability-zone would return zone names under a locationType saying they are IDs or ARNs, which a caller matching the two would silently mis-read.
That is exactly the failure mode this issue's consumer would hit, given its invariant that AZ names are never persisted or compared. So the decision was right and the fix is not to relax it — it is to make the first half of that sentence false by keying offerings by AZ ID properly.
The mapping this issue asks for is already built, in one place
ec2SeededZones(region) (ec2_plugin.go:4752) is the only producer of zones, and it emits both forms from the same loop: ZoneName: region + suffix and ZoneID: azRegionAbbrev(region) + "-az" + strconv.Itoa(i+1). DescribeAvailabilityZones (:4775) renders straight from it, so us-east-1a ↔ use1-az1 is guaranteed consistent rather than derived twice.
azRegionAbbrev's doc comment (:4969-4991) records both the derivation and its limit: AWS's "first three letters of the Region code" sentence is refuted by AWS's own table for compound directions (ap-southeast-2 → apse2, not aps2), so the walk is one letter per compass word; and the per-account shuffle is not modeled — "Substrate maps zone a to -az1 always, because a deterministic emulator cannot have a per-account secret and a test asserting a pairing must be able to pass."
That last point is the one thing to flag for this consumer: the emulator's use1-az1 is stably us-east-1a, whereas in a real account the pairing is per-account and arbitrary. A consumer whose whole invariant is "AZ names are per-account randomised, never persisted or compared" is correct against AWS and will find substrate more forgiving than production — so a test that accidentally depends on use1-az1 == us-east-1a passes here and would be meaningless there. Worth an acceptance criterion that the offerings response is asserted against DescribeAvailabilityZones' zoneId rather than against a literal.
What the change is
A fifth arm: case "availability-zone-id": collecting az.ZoneID from ec2SeededZones(reqCtx.Region) — not a reimplementation of the abbreviation, so the two forms cannot drift.
ec2UnmodelledLocationTypeError narrows to outpost alone, and its doc comment loses the "does not key offerings by them" clause. The comment is the recorded decision, so it has to change with the behaviour rather than after it.
The existing location filter needs no change — it compares against whatever locations holds, so filtering by use1-az1 works the moment the arm exists.
docs/services.md's unmodelled-LocationType note, and a test asserting locationType echoes availability-zone-id while location carries the ID (the response echoes locationType per item at :5791, so the mismatch this issue is about would be visible in the body).
Two adjacent gaps, for the record rather than for this issue
MaxResults and NextToken are unimplemented here. The handler's own doc comment lists the reference's parameters as "DryRun, Filter.N, LocationType, MaxResults and NextToken", and the code reads only the middle two — so a caller paginating gets the whole set on every call with no nextToken. Not this issue's scope, but it is the same operation and worth folding into whichever release takes this.
availability-zone-id is accepted as a filter name on five other EC2 describes and evaluated on none of them — ec2_filters.go:681 marks it accepted and inert, with ec2_filters.go:671 recording "Only availability-zone-id is inert: substrate derives a zone ID…". Once offerings key by AZ ID, those inert arms become implementable from the same ec2SeededZones pairing, which is a strictly larger follow-up.
Sizing
S — one switch arm, one comment reversal, one docs line, tests. Set to v0.117.0 rather than deferred with the rest of this batch: it is cheap, it reverses a recorded decision (so it wants to be written down while the reasoning is fresh), and unlike #891/#892/#894 it does not depend on the instance-type catalog gaining current-generation types, since it changes the location axis and not the type axis.
Activity
scttfrdmn commentedon Sep 15, 2026
Confirmed, and this one is small — smaller than the issue's framing suggests, because the pairing it asks for already exists and is already the single source of truth for both forms.
The refusal is a recorded decision, not an oversight
describeInstanceTypeOfferings(emulator/ec2_plugin.go:5729) builds its location list in a four-arm switch at:5749-5760:availability-zone(the default) enumeratesreqCtx.Region + suffixoverec2SeededAZSuffixes,regionreturns the one region, andavailability-zone-idandoutpostfall toec2UnmodelledLocationTypeError(ec2_instancetypes.go:294).defaultfalls toec2InvalidLocationTypeError(:277), which exists because "DescribeInstanceTypeOfferings' reference gives the valid values asregion | availability-zone | availability-zone-id | outpost, so a value outside that set is a bad request whether or not substrate models it" — i.e. the two errors are deliberately distinct, and the message naming substrate is deliberate too.The reason recorded for refusing rather than aliasing is worth quoting, because it is the argument this issue has to answer, and it holds:
That is exactly the failure mode this issue's consumer would hit, given its invariant that AZ names are never persisted or compared. So the decision was right and the fix is not to relax it — it is to make the first half of that sentence false by keying offerings by AZ ID properly.
The mapping this issue asks for is already built, in one place
ec2SeededZones(region)(ec2_plugin.go:4752) is the only producer of zones, and it emits both forms from the same loop:ZoneName: region + suffixandZoneID: azRegionAbbrev(region) + "-az" + strconv.Itoa(i+1).DescribeAvailabilityZones(:4775) renders straight from it, sous-east-1a↔use1-az1is guaranteed consistent rather than derived twice.azRegionAbbrev's doc comment (:4969-4991) records both the derivation and its limit: AWS's "first three letters of the Region code" sentence is refuted by AWS's own table for compound directions (ap-southeast-2→apse2, notaps2), so the walk is one letter per compass word; and the per-account shuffle is not modeled — "Substrate maps zone a to -az1 always, because a deterministic emulator cannot have a per-account secret and a test asserting a pairing must be able to pass."That last point is the one thing to flag for this consumer: the emulator's
use1-az1is stablyus-east-1a, whereas in a real account the pairing is per-account and arbitrary. A consumer whose whole invariant is "AZ names are per-account randomised, never persisted or compared" is correct against AWS and will find substrate more forgiving than production — so a test that accidentally depends onuse1-az1 == us-east-1apasses here and would be meaningless there. Worth an acceptance criterion that the offerings response is asserted againstDescribeAvailabilityZones'zoneIdrather than against a literal.What the change is
case "availability-zone-id":collectingaz.ZoneIDfromec2SeededZones(reqCtx.Region)— not a reimplementation of the abbreviation, so the two forms cannot drift.ec2UnmodelledLocationTypeErrornarrows tooutpostalone, and its doc comment loses the "does not key offerings by them" clause. The comment is the recorded decision, so it has to change with the behaviour rather than after it.locationfilter needs no change — it compares against whateverlocationsholds, so filtering byuse1-az1works the moment the arm exists.docs/services.md's unmodelled-LocationType note, and a test assertinglocationTypeechoesavailability-zone-idwhilelocationcarries the ID (the response echoeslocationTypeper item at:5791, so the mismatch this issue is about would be visible in the body).Two adjacent gaps, for the record rather than for this issue
MaxResultsandNextTokenare unimplemented here. The handler's own doc comment lists the reference's parameters as "DryRun,Filter.N,LocationType,MaxResultsandNextToken", and the code reads only the middle two — so a caller paginating gets the whole set on every call with nonextToken. Not this issue's scope, but it is the same operation and worth folding into whichever release takes this.availability-zone-idis accepted as a filter name on five other EC2 describes and evaluated on none of them —ec2_filters.go:681marks itacceptedand inert, withec2_filters.go:671recording "Only availability-zone-id is inert: substrate derives a zone ID…". Once offerings key by AZ ID, those inert arms become implementable from the sameec2SeededZonespairing, which is a strictly larger follow-up.Sizing
S — one switch arm, one comment reversal, one docs line, tests. Set to v0.117.0 rather than deferred with the rest of this batch: it is cheap, it reverses a recorded decision (so it wants to be written down while the reasoning is fresh), and unlike #891/#892/#894 it does not depend on the instance-type catalog gaining current-generation types, since it changes the location axis and not the type axis.
feat(ec2): key instance-type offerings by AZ ID (#893)
feat(ec2): key instance-type offerings by AZ ID (#893) (#897)