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: On-Demand Capacity Reservation API (Create/Cancel/DescribeCapacityReservations) #891
The EC2 endpoint returns InvalidAction for CreateCapacityReservation, DescribeCapacityReservations, and CancelCapacityReservation (substrate v0.116.0, substrate server).
Repro (SDK/CLI at http://localhost:4566):
aws ec2 create-capacity-reservation --instance-type g6.xlarge --instance-platform Linux/UNIX \
--availability-zone us-east-1a --instance-count 1 \
--tag-specifications 'ResourceType=capacity-reservation,Tags=[{Key=sonde:run,Value=r1}]'
# -> InvalidAction: The action CreateCapacityReservation is not valid for this endpoint.
Consumer / why:sonde (github.com/scttfrdmn/sonde) uses immediate On-Demand Capacity Reservations as its primary probe primitive. To test it deterministically against substrate instead of a real account, the emulator needs:
Create — inputs instance type, AZ, platform, tenancy, count; tags applied in the create call must be readable back (sonde tags sonde:run/sonde:probe/sonde:created at creation). Returns a CapacityReservationId, State, StartDate.
Describe — filterable (at least by state), returns Tags, State, StartDate — sonde's reaper enumerates by tag and cancels by age.
Cancel — transitions to cancelled.
Seedable outcomes — the value for sonde is distinguishing capacity vs account-side failures. Ideally seed a cell to return InsufficientInstanceCapacity, InstanceLimitExceeded/VcpuLimitExceeded, Unsupported, or RequestLimitExceeded so the outcome-mapping path can be exercised end to end.
Fulfilled create + tag readback + cancel + describe-by-tag would unblock sonde's M1 (reaper + ODCR prober); seedable errors would let the full outcome map be integration-tested.
Confirmed, and it is the same defect class as #885: all three actions are authorizable but not dispatched.emulator/authz_reference_gen.go:128 carries "ec2:CreateCapacityReservation": {"capacity-reservation"}, :108CancelCapacityReservation and :732DescribeCapacityReservations, so a consumer can be granted permission to make a call that answers InvalidAction. Outside those generated entries the string CapacityReservation does not appear anywhere in emulator/ — no state type, no handler, no arm in the EC2 dispatch switch (ec2_plugin.go:72-264), and no CapacityReservationSpecification on RunInstances. This is a from-scratch resource, not a gap in an existing one.
Everything below is quoted from the API reference except where marked.
API_CancelCapacityReservation — CapacityReservationId required; ApplyCancellationCharges (sole value commitment-wind-down), DryRun, QuoteId optional. Response is return (boolean) + requestId: "Returns true if the request succeeds; otherwise, it returns an error."
API_DescribeCapacityReservations — CapacityReservationId.N, DryRun, Filter.N, MaxResults ("Minimum value of 1. Maximum value of 1000."), NextToken. Response capacityReservationSet, nextToken ("This value is null when there are no more results to return."), requestId.
InstancePlatform publishes eighteen values: Linux/UNIX | Red Hat Enterprise Linux | SUSE Linux | Windows | Windows with SQL Server | Windows with SQL Server Enterprise | Windows with SQL Server Standard | Windows with SQL Server Web | Linux with SQL Server Standard | Linux with SQL Server Web | Linux with SQL Server Enterprise | RHEL with SQL Server Standard | RHEL with SQL Server Enterprise | RHEL with SQL Server Web | RHEL with HA | RHEL with HA and SQL Server Standard | RHEL with HA and SQL Server Enterprise | Ubuntu Pro. EndDateType: unlimited | limited. InstanceMatchCriteria: open | targeted. Tenancy: default | dedicated. DeliveryPreference: fixed | incremental.
API_CapacityReservation has 32 members, of which the ones this issue needs are capacityReservationId, capacityReservationArn, state, startDate, createDate, endDate, endDateType, instanceType, instancePlatform, availabilityZone, availabilityZoneId, tenancy, totalInstanceCount, availableInstanceCount, instanceMatchCriteria, ownerId and TagSet.N.
Three findings that change what this issue asks for
1. State is documented twice, with different value sets, and the two disagree. The CapacityReservation type publishes thirteen: active | expired | cancelled | pending | failed | scheduled | payment-pending | payment-failed | assessing | delayed | unsupported | cancelling | unavailable. The statefilter on DescribeCapacityReservations enumerates only five — active, expired, cancelled, pending, failed — and glosses each. That is a divergence inside AWS's own reference, of the kind v0.116.0 spent its ## Provenance section on, and it should be recorded rather than quietly resolved. The five-value set is the one to model, since it is the set AWS documents as filterable and it covers this issue's whole lifecycle; the other eight are Capacity Block and billing states with no modeled subsystem behind them. Refusing an unmodeled state filter value is what ec2InvalidFilterError's siblings already do.
2. TagSpecifications is supported but the page does not say which ResourceType value it takes — API_CreateCapacityReservation states only "The tags to apply to the Capacity Reservation during launch." The value in this issue's repro (ResourceType=capacity-reservation) is nevertheless sourced from an AWS document, just a different one: the vendored authorization reference gives capacity-reservation as the resource type for ec2:CreateCapacityReservation (authz_reference_gen.go:128, from authzref/ec2.json:454). Worth citing that rather than the API page, because the API page cannot support it.
Tag-on-create then needs no new machinery: ec2CheckTagSpecificationTypes(params, "capacity-reservation") (ec2_tags.go:225) refuses a specification scoped to anything else, and ec2LaunchTagsForResource (:190) collects the tags. The pair must be used together — ec2TagSpecificationTags silently skips a non-matching scope, which is right for CreateImage (which tags an AMI and its snapshots) and wrong here, where a skip drops the caller's tags and reports success. That reasoning is already written out at ec2_tags.go:207-224.
3. Requirement 2's "describe-by-tag" cannot be met through the published filter set, and this is the one place the issue's plan needs revising.Filter.N publishes exactly twelve names — instance-type, owner-id, instance-platform, availability-zone, tenancy, outpost-arn, state, start-date, end-date, end-date-type, instance-match-criteria, placement-group-arn — and neither tag:<key> nor tag-key is among them. (Nor is availability-zone-id, though the type carries availabilityZoneId — the same asymmetry #893 is about.) Whether real EC2 accepts an undocumented tag: filter here is unverified; no capture exists. Substrate's filter machinery refuses an unknown filter name by construction (ec2InvalidFilterError, ec2_instancetypes.go:261), and following the published list is the honest choice.
So a reaper enumerating by tag has to filter client-side on TagSet from an unfiltered DescribeCapacityReservations, which the tags-readable-on-create requirement already supports. Cancelling by age likewise reads createDate/startDate client-side, since start-date as a filter takes an instant rather than an age. Requirement 2 is still satisfiable, just not by the server — and the issue should say so, because "describe-by-tag" reads as a server-side filter that AWS does not offer.
Seedable outcomes — the codes are substrate's reading, and there is a precedent to copy
None of the three operations publishes an operation-specific Errors section. All three say only "For information about the errors that are common to all actions, see Common Error Types." So InsufficientInstanceCapacity, InstanceLimitExceeded, VcpuLimitExceeded, Unsupported and RequestLimitExceeded are not published for these operations — any of them substrate answers comes from EC2's client-error table and must be labelled substrate's reading, exactly as ec2CheckTagSpecificationTypes' own provenance note does.
That is not an obstacle: the tree already answers InsufficientInstanceCapacity on the same footing for fleets (ec2_fleet.go:252, defaulted at ec2_fleet_control.go:35). And ec2FleetShortfall is the seed to copy wholesale — a namespace (ec2FleetCtrlNamespace), a key built by ec2FleetCtrlKey with a "*" wildcard, resolution that tries the specific key then the wildcard (resolveFleetShortfall), and POST/DELETE /v1/ec2/fleet-shortfall handlers. Its doc comment states the rationale this issue restates: "Substrate never runs a real capacity broker; a seed lets a test set … which error the shortfall reports." A capacity-reservation seed keyed by instance type (or "*") is the same shape, and #387 is its precedent.
The nominal path stays a success: stateactive, availableInstanceCount equal to totalInstanceCount, startDate from the simulated clock. pending and failed are seeded outcomes, not timing artefacts.
Two things needing a decision, and one that needs none
capacityReservationId has no published format. The reference gives Type: String and no pattern, while it does publish patterns for outpostArn and placementGroupArn — so the identifier shape is unverified and whatever substrate mints is its own reading, minted through randomHex (ec2_types.go:489) like every other EC2 ID. That is the same position cfn: an origin access identity reports its logical ID as its physical ID, and its Comment lookup reads a dotted key in a flat map #859 was in for the CloudFront OAI, except with no published sample to anchor on, so the decision should be recorded in the minter's doc comment.
No authorization-reference change is needed — all three actions are already present with their resource types, so each handler needs only its p.authorize(...) line.
One cross-cutting blocker
The repro launches g6.xlarge, and substrate's instance-type catalog has ten families — c5, c5a, g4dn, inf1, m5, m5a, p3, r5, t3, t3a — with no g6, g5, p4, p5, trn1 or inf2 (ec2_instancetypes.go:76-167). RunInstances does not validate the type against the catalog, but DescribeInstanceTypes, DescribeInstanceTypeOfferings and DescribeSpotPriceHistory all do or derive from it (ec2CheckInstanceTypesExist, :241), so a probe for a current-generation accelerated type is refused before any of #891, #892 or #894 matters. Filed as #896, since it blocks all three.
Sizing
L, and the largest single item in this batch: a state type, three handlers, tag-on-create, twelve filter names through the existing ec2*FilterSpec machinery, MaxResults/NextToken pagination, the seed pair with its two control endpoints, the tagging-API arm and scanner, plus docs/services.md. Moved to v0.118.0 as the headline rather than squeezed into v0.117.0, which already carries eighteen issues.
The API shapes for all three operations are now verified against the reference, and three wire names in the repro and in the issue's own framing are wrong. Recording them before implementing, because each would produce an operation that accepts nothing the SDK sends.
DescribeCapacityReservations takes CapacityReservationId.N, singular. The CLI's --capacity-reservation-ids flattens to that, which is why the plural form looks right from the
consumer side.
CreateCapacityReservation — only three parameters are required
InstanceCount, InstancePlatform and InstanceType. AvailabilityZone is Required: No — it
or AvailabilityZoneId, and the page does not say one of the pair is mandatory. The repro passes --availability-zone, so this is not a problem for sonde, but a validation that requires it would
refuse a request AWS accepts.
InstanceCount — the range is published as prose, "Valid range: 1 - 1000", not as a Valid Range: constraint line. Worth noting because substrate's convention is to enforce published
ranges, and this one is only prose.
InstancePlatform — 19 values, not the handful a reader might assume: Linux/UNIX | Red Hat Enterprise Linux | SUSE Linux | Windows | Windows with SQL Server | Windows with SQL Server Enterprise | Windows with SQL Server Standard | Windows with SQL Server Web | Linux with SQL Server Standard | Linux with SQL Server Web | Linux with SQL Server Enterprise | RHEL with SQL Server Standard | RHEL with SQL Server Enterprise | RHEL with SQL Server Web | RHEL with HA | RHEL with HA and SQL Server Standard | RHEL with HA and SQL Server Enterprise | Ubuntu Pro
Tenancy — default | dedicated. Note default, not shared.
EndDateType — unlimited | limited, with a genuine mutual constraint the page states both ways: limited"You must provide an EndDate value", unlimited"Do not provide an EndDate".
InstanceMatchCriteria — open | targeted, Default: open.
EphemeralStorage — published as Deprecated., so it is accepted and means nothing.
DeliveryPreference — fixed | incremental, with the page itself saying "The only supported value
is incremental."
Future-dated-only parameters, all Required: No: StartDate ("between 5 and 120 days in
advance"), CommitmentDuration (1 … 200000000), and InstanceMatchCriteria forced to targeted.
CreateCapacityReservation returns the full CapacityReservation structure, not just an ID — the
response elements are capacityReservation and requestId. So criterion 1's "Returns a CapacityReservationId, State, StartDate" is satisfied automatically and then some; there is no
separate describe needed to read back the tags.
A newly created immediate reservation reports State=active right away. All three CLI examples
show "State": "active", and the User Guide states "the reserved capacity becomes available for use
immediately after you create it, and billing starts as soon as the Capacity Reservation enters the
active state."pending exists in the enum but is not the documented create result for an immediate
reservation — so the nominal success path is active, with no observation countdown, and pending is
a seedable alternative rather than the default.
DescribeCapacityReservations — the filter list is twelve names, and state is not the only useful one
Complete and exhaustive, quoted from the page: instance-type, owner-id, instance-platform, availability-zone, tenancy, outpost-arn, state, start-date, end-date, end-date-type, instance-match-criteria, placement-group-arn.
There is noavailability-zone-id, capacity-reservation-id, create-date, instance-count or reservation-type filter documented, so those are refused rather than inert.
MaxResults is 1 … 1000 as a real Valid Range: line. Scoping prose: "The results describe only
the Capacity Reservations in the AWS Region that you're currently using."
One documented inconsistency to decide on rather than inherit: the statefilter publishes five
values (active, expired, cancelled, pending, failed) while the CapacityReservation.state member publishes thirteen. The type page is the fuller list, so a filter on a state the filter
section omits is a case AWS's own documentation does not resolve.
Note criterion 2 says sonde's reaper "enumerates by tag". There is no tag filter in the twelve,
so enumeration by tag goes through the generic tag:<key> / tag-key filter convention EC2 applies
across its Describe operations rather than through anything on this page. That needs to be explicit,
because it is the difference between the reaper working and returning everything.
CancelCapacityReservation
CapacityReservationId is the only required parameter; ApplyCancellationCharges
(commitment-wind-down only), QuoteId and DryRun are optional. Response is requestId and return (Boolean) — not a reservation structure.
"Cancels the specified Capacity Reservation, releases the reserved capacity, and changes the Capacity
Reservation's state to cancelled." So criterion 3 is exactly right. The page also enumerates which
states are cancellable — assessing, scheduled, active, and delayed — which means cancelling an
already-cancelled or expired reservation is a refusal, and "You can't modify or cancel a Capacity
Block."
The active-during-commitment path goes active → cancelling → cancelled, but it requires a
cancellation quote from CreateCapacityReservationCancellationQuote, which is out of scope here.
The state enumeration is thirteen values, and one is undocumented
unavailable appears in the Valid Values line with no prose description anywhere on the page.
Nine of the thirteen belong to future-dated reservations or Capacity Blocks, neither of which this
issue asks for, so the seedable set should be the ones an immediate reservation can actually reach — active, pending, failed, expired, cancelled — with the rest recorded as unmodelled rather
than silently absent.
failed is the interesting one for criterion 4: "A request can fail due to request parameters that
are not valid, capacity constraints, or instance limit constraints. You can view a failed request for
60 minutes." That is a state, not an error — so a capacity failure has two possible observable
shapes, and which one AWS produces is not stated.
Criterion 4's error codes — all five are real, and two are classified as server errors
All five are on errors-overview.html. That page's tables have only Error code | Description — no
per-code HTTP status column. Status is given as a class only: client errors "are accompanied by a
400-series HTTP response code", server errors "a 500-series HTTP response code".
Code
Table
Implied HTTP
InsufficientInstanceCapacity
Server
500-series
InstanceLimitExceeded
Client, specific actions
400-series
VcpuLimitExceeded
Client, specific actions
400-series
Unsupported
Client, specific actions
400-series
RequestLimitExceeded
Server
500-series
Two of the five name Capacity Reservations explicitly, which is unusually good provenance:
InsufficientInstanceCapacity — "There is not enough capacity to fulfill your request. This error
can occur if you launch a new instance, restart a stopped instance, create a new Capacity
Reservation, or modify an existing Capacity Reservation."
InstanceLimitExceeded — "This error can occur if you are launching an instance or if you are creating a Capacity Reservation. Capacity Reservations count towards your On-Demand Instance
limits."
Two things that need deciding explicitly rather than inherited:
InsufficientInstanceCapacity being a 500-series code is counter-intuitive for what a consumer
treats as a capacity signal, and sonde's whole purpose is distinguishing capacity from account-side
failure. Substrate should answer the documented class, not the intuitive one, and say so — an
emulator that answered 400 would let a consumer's retry logic pass a test it fails in production.
The same page elsewhere writes the throttle code with a client prefix — "If your requests have
been throttled, you get the following error: Client.RequestLimitExceeded." — contradicting its
own server-table entry. CommonErrors.html does not list RequestLimitExceeded at all.
Exact numeric statuses (500 vs 503) are UNVERIFIED: neither page assigns them.
Also available and arguably better fits than two of the five: UnsupportedException — "Capacity
Reservations are not supported for this Region." — and UnsupportedTenancy. And for ClientToken
reuse, IdempotentParameterMismatch: "The request uses the same client token as a previous, but
non-identical request."
No sample response is published
None of the four pages (CreateCapacityReservation, DescribeCapacityReservations, CancelCapacityReservation, CapacityReservation) publishes an Examples section or any sample XML.
The only verbatim XML on the reference is the generic error envelope. So the success-response element
names come from the member lists above and the item-wrapper nesting rests on substrate's existing
EC2 query-protocol rendering, not on a citation — that should be stated rather than implied.
What this changes about the issue
Nothing in the four criteria is wrong in substance. The corrections are the three wire names, the fact
that create already returns everything describe would (so tag readback needs no second call), that AvailabilityZone is not required, that tag enumeration is not one of the twelve documented filters,
and that a capacity failure has two documented shapes — a failed state and a 500-series error code —
where the issue assumes only the second.
Implemented in #1032. Six corrections to what is already on this issue, and the decisions that were
left open above, resolved on the record.
Corrections to my own earlier comments
InstancePlatform publishes eighteen values, not nineteen. The second comment's list is wrong:
there is no RHEL with HA and SQL Server Web. The eighteen are Linux/UNIX, Red Hat Enterprise Linux, SUSE Linux, Windows, Windows with SQL Server, Windows with SQL Server Enterprise, Windows with SQL Server Standard, Windows with SQL Server Web, Linux with SQL Server Standard, Linux with SQL Server Web, Linux with SQL Server Enterprise, RHEL with SQL Server Standard, RHEL with SQL Server Enterprise, RHEL with SQL Server Web, RHEL with HA, RHEL with HA and SQL Server Standard, RHEL with HA and SQL Server Enterprise, Ubuntu Pro —
which is what the first comment says. Only Windows and Linux carry a Web SQL Server variant; RHEL with HA carries Standard and Enterprise only. Eighteen is what is enforced.
The state filter is not restricted to the five documented values. My first comment proposed
refusing an unmodelled state filter value. Substrate does not do that: the filter matches
against whatever the reservation reports, and a value outside the five simply matches nothing. The
filter's own published enumeration is a statement about what a reservation can be, not a
validation rule, and refusing a well-formed value AWS's own type page publishes would be a
difference from AWS on the strength of a gloss. The narrowing that is enforced is on the seed — five of the thirteen states are seedable — because seeding a state substrate models no
subsystem behind would publish an observation nothing else in the emulator is consistent with.
capacityReservationId's shape. No published pattern exists, as recorded above, so substrate
mints cr- + 17 lowercase hex through the same randomHex every other EC2 ID uses. That is
stated in the minter's doc comment as substrate's reading.
AvailabilityZone and AvailabilityZoneId are neither required nor mutually required. Both
are Required: No and the page states no rule on the pair, so a request naming neither is
accepted and reports neither element. A zone name is recorded as given and never validated; a
zone ID must resolve, because it has to be translated to the name the response reports. A pair
naming two different zones answers InvalidParameterCombination — that one is substrate's reading,
since the page does not address the case.
No code exists for cancelling from a non-cancellable state. All three operations carry only the
common-errors boilerplate, the sole state-shaped code in the reference is InvalidCapacityReservationState.PendingActivation (a Capacity Block that is not active yet), and
AWS's own sample tooling pre-checks the state through a describe rather than catching an error.
Substrate answers IncorrectState/400 as its reading, which is what it already answers for
this shape on a volume and a snapshot.
The open decisions, resolved
EndDateType is inferred, not defaulted. AWS publishes no Default: line and forbids exactly
two combinations — limited with no EndDate, unlimited with one — so an EndDate alone infers limited and no EndDate infers unlimited. Defaulting an absent EndDateType to unlimited
would turn a request naming only an EndDate, which nothing forbids, into the second refusal.
A future-dated reservation is refused, not answered falsely.StartDate and CommitmentDuration each answer Unsupported/400. Eight of the thirteen state values exist only
for a future-dated reservation or a Capacity Block, and answering active to a request for capacity
two days out would be a false observation carrying nothing to tell a caller the request was not
modelled.
Expiry is derived at observation time from the simulated clock, per endDate's own sentence, so
it is assertable without wall-clock dependence. Only an active reservation expires: a seeded failed one has already reached a terminal state, and reporting expired for it would lose the
outcome the test seeded.
InstanceCount is enforced at 1–1000 even though the range is prose rather than a Valid Range: line, and InstanceCount is not otherwise consumed, because nothing occupies a
reservation.
The seed follows this issue's two-shapes finding rather than only its criterion 4. POST/DELETE /v1/ec2/capacity-reservation-outcomes takes errorCodeorstate, refusing a
request naming both — since which shape AWS produces for a given cell is not documented, the choice
belongs to the test. Scoping is (instance type, Availability Zone) with either half omittable, and
the most specific scope carrying a seed decides: cell, then type in any zone, then any type in the
zone, then wildcard. Type before zone is substrate's ordering, because a seed naming a type is the
narrower claim.
IdempotentParameterMismatch is not answered, because ClientToken is accepted and inert —
there is no idempotency ledger for a mismatch to be detected against. Two identical creates make
two reservations.
UnsupportedException/UnsupportedTenancy are not used.Unsupported covers the two shapes
substrate refuses (a future-dated request), and adding a Region- or tenancy-specific code would
require modeling which Regions and tenancies offer a reservation, which substrate does not.
Acceptance criteria
All four are met. Criterion 2's "describe-by-tag" is met client-side, exactly as my third
finding above said it would have to be: no tag: or tag-key filter is published for this
operation, so a reaper enumerates by reading tagSet from an unfiltered describe (or by DescribeTags on the cr- prefix) and cancels by createDate. docs/services.md records that as an
unmodelled path rather than leaving it to be discovered.
The g6.xlarge in the repro still needs #896: CreateCapacityReservation does not validate the
instance type against the catalog — nothing here refuses an uncatalogued type — so the repro runs
today, but DescribeInstanceTypes alongside it will not report g6.xlarge until #896 lands.
Activity
scttfrdmn commentedon Sep 15, 2026
Confirmed, and it is the same defect class as #885: all three actions are authorizable but not dispatched.
emulator/authz_reference_gen.go:128carries"ec2:CreateCapacityReservation": {"capacity-reservation"},:108CancelCapacityReservationand:732DescribeCapacityReservations, so a consumer can be granted permission to make a call that answersInvalidAction. Outside those generated entries the stringCapacityReservationdoes not appear anywhere inemulator/— no state type, no handler, no arm in the EC2 dispatch switch (ec2_plugin.go:72-264), and noCapacityReservationSpecificationonRunInstances. This is a from-scratch resource, not a gap in an existing one.Everything below is quoted from the API reference except where marked.
Verified request/response shapes
API_CreateCapacityReservation— three required parameters:InstanceCount,InstancePlatform,InstanceType. Optional:AvailabilityZone,AvailabilityZoneId,ClientToken,CommitmentDuration,DeliveryPreference,DryRun,EbsOptimized,EndDate,EndDateType,EphemeralStorage,InstanceMatchCriteria,OutpostArn,PlacementGroupArn,StartDate,TagSpecifications.N,Tenancy. Response iscapacityReservation+requestId.API_CancelCapacityReservation—CapacityReservationIdrequired;ApplyCancellationCharges(sole valuecommitment-wind-down),DryRun,QuoteIdoptional. Response isreturn(boolean) +requestId: "Returns true if the request succeeds; otherwise, it returns an error."API_DescribeCapacityReservations—CapacityReservationId.N,DryRun,Filter.N,MaxResults("Minimum value of 1. Maximum value of 1000."),NextToken. ResponsecapacityReservationSet,nextToken("This value isnullwhen there are no more results to return."),requestId.InstancePlatformpublishes eighteen values:Linux/UNIX | Red Hat Enterprise Linux | SUSE Linux | Windows | Windows with SQL Server | Windows with SQL Server Enterprise | Windows with SQL Server Standard | Windows with SQL Server Web | Linux with SQL Server Standard | Linux with SQL Server Web | Linux with SQL Server Enterprise | RHEL with SQL Server Standard | RHEL with SQL Server Enterprise | RHEL with SQL Server Web | RHEL with HA | RHEL with HA and SQL Server Standard | RHEL with HA and SQL Server Enterprise | Ubuntu Pro.EndDateType:unlimited | limited.InstanceMatchCriteria:open | targeted.Tenancy:default | dedicated.DeliveryPreference:fixed | incremental.API_CapacityReservationhas 32 members, of which the ones this issue needs arecapacityReservationId,capacityReservationArn,state,startDate,createDate,endDate,endDateType,instanceType,instancePlatform,availabilityZone,availabilityZoneId,tenancy,totalInstanceCount,availableInstanceCount,instanceMatchCriteria,ownerIdandTagSet.N.Three findings that change what this issue asks for
1.
Stateis documented twice, with different value sets, and the two disagree. TheCapacityReservationtype publishes thirteen:active | expired | cancelled | pending | failed | scheduled | payment-pending | payment-failed | assessing | delayed | unsupported | cancelling | unavailable. Thestatefilter onDescribeCapacityReservationsenumerates only five —active,expired,cancelled,pending,failed— and glosses each. That is a divergence inside AWS's own reference, of the kind v0.116.0 spent its## Provenancesection on, and it should be recorded rather than quietly resolved. The five-value set is the one to model, since it is the set AWS documents as filterable and it covers this issue's whole lifecycle; the other eight are Capacity Block and billing states with no modeled subsystem behind them. Refusing an unmodeledstatefilter value is whatec2InvalidFilterError's siblings already do.2.
TagSpecificationsis supported but the page does not say whichResourceTypevalue it takes —API_CreateCapacityReservationstates only "The tags to apply to the Capacity Reservation during launch." The value in this issue's repro (ResourceType=capacity-reservation) is nevertheless sourced from an AWS document, just a different one: the vendored authorization reference givescapacity-reservationas the resource type forec2:CreateCapacityReservation(authz_reference_gen.go:128, fromauthzref/ec2.json:454). Worth citing that rather than the API page, because the API page cannot support it.Tag-on-create then needs no new machinery:
ec2CheckTagSpecificationTypes(params, "capacity-reservation")(ec2_tags.go:225) refuses a specification scoped to anything else, andec2LaunchTagsForResource(:190) collects the tags. The pair must be used together —ec2TagSpecificationTagssilently skips a non-matching scope, which is right forCreateImage(which tags an AMI and its snapshots) and wrong here, where a skip drops the caller's tags and reports success. That reasoning is already written out atec2_tags.go:207-224.3. Requirement 2's "describe-by-tag" cannot be met through the published filter set, and this is the one place the issue's plan needs revising.
Filter.Npublishes exactly twelve names —instance-type,owner-id,instance-platform,availability-zone,tenancy,outpost-arn,state,start-date,end-date,end-date-type,instance-match-criteria,placement-group-arn— and neithertag:<key>nortag-keyis among them. (Nor isavailability-zone-id, though the type carriesavailabilityZoneId— the same asymmetry #893 is about.) Whether real EC2 accepts an undocumentedtag:filter here is unverified; no capture exists. Substrate's filter machinery refuses an unknown filter name by construction (ec2InvalidFilterError,ec2_instancetypes.go:261), and following the published list is the honest choice.So a reaper enumerating by tag has to filter client-side on
TagSetfrom an unfilteredDescribeCapacityReservations, which the tags-readable-on-create requirement already supports. Cancelling by age likewise readscreateDate/startDateclient-side, sincestart-dateas a filter takes an instant rather than an age. Requirement 2 is still satisfiable, just not by the server — and the issue should say so, because "describe-by-tag" reads as a server-side filter that AWS does not offer.Seedable outcomes — the codes are substrate's reading, and there is a precedent to copy
None of the three operations publishes an operation-specific
Errorssection. All three say only "For information about the errors that are common to all actions, see Common Error Types." SoInsufficientInstanceCapacity,InstanceLimitExceeded,VcpuLimitExceeded,UnsupportedandRequestLimitExceededare not published for these operations — any of them substrate answers comes from EC2's client-error table and must be labelled substrate's reading, exactly asec2CheckTagSpecificationTypes' own provenance note does.That is not an obstacle: the tree already answers
InsufficientInstanceCapacityon the same footing for fleets (ec2_fleet.go:252, defaulted atec2_fleet_control.go:35). Andec2FleetShortfallis the seed to copy wholesale — a namespace (ec2FleetCtrlNamespace), a key built byec2FleetCtrlKeywith a"*"wildcard, resolution that tries the specific key then the wildcard (resolveFleetShortfall), andPOST/DELETE /v1/ec2/fleet-shortfallhandlers. Its doc comment states the rationale this issue restates: "Substrate never runs a real capacity broker; a seed lets a test set … which error the shortfall reports." A capacity-reservation seed keyed by instance type (or"*") is the same shape, and #387 is its precedent.The nominal path stays a success:
stateactive,availableInstanceCountequal tototalInstanceCount,startDatefrom the simulated clock.pendingandfailedare seeded outcomes, not timing artefacts.Two things needing a decision, and one that needs none
capacityReservationIdhas no published format. The reference givesType: Stringand no pattern, while it does publish patterns foroutpostArnandplacementGroupArn— so the identifier shape is unverified and whatever substrate mints is its own reading, minted throughrandomHex(ec2_types.go:489) like every other EC2 ID. That is the same position cfn: an origin access identity reports its logical ID as its physical ID, and its Comment lookup reads a dotted key in a flat map #859 was in for the CloudFront OAI, except with no published sample to anchor on, so the decision should be recorded in the minter's doc comment.resolveARNintagging_plugin.goneeds acapacity-reservationarm andscanAllResourcesa scanner, orGetResourceswill not report a reservation thatCreateCapacityReservationtagged. That is the The Resource Groups Tagging API cannot write tags for eleven types: mergeResourceTags has no arm #835 class, and adding a new taggable resource without it repeats exactly what The Resource Groups Tagging API cannot write tags for eleven types: mergeResourceTags has no arm #835 exists to clean up.p.authorize(...)line.One cross-cutting blocker
The repro launches
g6.xlarge, and substrate's instance-type catalog has ten families —c5,c5a,g4dn,inf1,m5,m5a,p3,r5,t3,t3a— with nog6,g5,p4,p5,trn1orinf2(ec2_instancetypes.go:76-167).RunInstancesdoes not validate the type against the catalog, butDescribeInstanceTypes,DescribeInstanceTypeOfferingsandDescribeSpotPriceHistoryall do or derive from it (ec2CheckInstanceTypesExist,:241), so a probe for a current-generation accelerated type is refused before any of #891, #892 or #894 matters. Filed as #896, since it blocks all three.Sizing
L, and the largest single item in this batch: a state type, three handlers, tag-on-create, twelve filter names through the existing
ec2*FilterSpecmachinery,MaxResults/NextTokenpagination, the seed pair with its two control endpoints, the tagging-API arm and scanner, plusdocs/services.md. Moved to v0.118.0 as the headline rather than squeezed into v0.117.0, which already carries eighteen issues.feat(ec2): seed eleven accelerated instance-type families completely (#…
scttfrdmn commentedon Sep 17, 2026
The API shapes for all three operations are now verified against the reference, and three wire names in the repro and in the issue's own framing are wrong. Recording them before implementing, because each would produce an operation that accepts nothing the SDK sends.
Wire names
CapacityReservationIds.NCapacityReservationId.NInstanceTypes.N(on the Spot sibling, #892)InstanceType.NRegionNames.N(on the Spot sibling, #892)RegionName.NDescribeCapacityReservationstakesCapacityReservationId.N, singular. The CLI's--capacity-reservation-idsflattens to that, which is why the plural form looks right from theconsumer side.
CreateCapacityReservation— only three parameters are requiredInstanceCount,InstancePlatformandInstanceType.AvailabilityZoneisRequired: No— itor
AvailabilityZoneId, and the page does not say one of the pair is mandatory. The repro passes--availability-zone, so this is not a problem for sonde, but a validation that requires it wouldrefuse a request AWS accepts.
InstanceCount— the range is published as prose, "Valid range: 1 - 1000", not as aValid Range:constraint line. Worth noting because substrate's convention is to enforce publishedranges, and this one is only prose.
InstancePlatform— 19 values, not the handful a reader might assume:Linux/UNIX | Red Hat Enterprise Linux | SUSE Linux | Windows | Windows with SQL Server | Windows with SQL Server Enterprise | Windows with SQL Server Standard | Windows with SQL Server Web | Linux with SQL Server Standard | Linux with SQL Server Web | Linux with SQL Server Enterprise | RHEL with SQL Server Standard | RHEL with SQL Server Enterprise | RHEL with SQL Server Web | RHEL with HA | RHEL with HA and SQL Server Standard | RHEL with HA and SQL Server Enterprise | Ubuntu ProTenancy—default | dedicated. Notedefault, notshared.EndDateType—unlimited | limited, with a genuine mutual constraint the page states both ways:limited"You must provide anEndDatevalue",unlimited"Do not provide anEndDate".InstanceMatchCriteria—open | targeted,Default: open.EphemeralStorage— published asDeprecated., so it is accepted and means nothing.DeliveryPreference—fixed | incremental, with the page itself saying "The only supported valueis
incremental."Required: No:StartDate("between 5 and 120 days inadvance"),
CommitmentDuration(1 … 200000000), andInstanceMatchCriteriaforced totargeted.CreateCapacityReservationreturns the fullCapacityReservationstructure, not just an ID — theresponse elements are
capacityReservationandrequestId. So criterion 1's "Returns aCapacityReservationId,State,StartDate" is satisfied automatically and then some; there is noseparate describe needed to read back the tags.
A newly created immediate reservation reports
State=activeright away. All three CLI examplesshow
"State": "active", and the User Guide states "the reserved capacity becomes available for useimmediately after you create it, and billing starts as soon as the Capacity Reservation enters the
active state."
pendingexists in the enum but is not the documented create result for an immediatereservation — so the nominal success path is
active, with no observation countdown, andpendingisa seedable alternative rather than the default.
DescribeCapacityReservations— the filter list is twelve names, andstateis not the only useful oneComplete and exhaustive, quoted from the page:
instance-type,owner-id,instance-platform,availability-zone,tenancy,outpost-arn,state,start-date,end-date,end-date-type,instance-match-criteria,placement-group-arn.There is no
availability-zone-id,capacity-reservation-id,create-date,instance-countorreservation-typefilter documented, so those are refused rather than inert.MaxResultsis1 … 1000as a realValid Range:line. Scoping prose: "The results describe onlythe Capacity Reservations in the AWS Region that you're currently using."
One documented inconsistency to decide on rather than inherit: the
statefilter publishes fivevalues (
active,expired,cancelled,pending,failed) while theCapacityReservation.statemember publishes thirteen. The type page is the fuller list, so a filter on a state the filter
section omits is a case AWS's own documentation does not resolve.
Note criterion 2 says sonde's reaper "enumerates by tag". There is no tag filter in the twelve,
so enumeration by tag goes through the generic
tag:<key>/tag-keyfilter convention EC2 appliesacross its Describe operations rather than through anything on this page. That needs to be explicit,
because it is the difference between the reaper working and returning everything.
CancelCapacityReservationCapacityReservationIdis the only required parameter;ApplyCancellationCharges(
commitment-wind-downonly),QuoteIdandDryRunare optional. Response isrequestIdandreturn(Boolean) — not a reservation structure."Cancels the specified Capacity Reservation, releases the reserved capacity, and changes the Capacity
Reservation's state to
cancelled." So criterion 3 is exactly right. The page also enumerates whichstates are cancellable —
assessing,scheduled,active, anddelayed— which means cancelling analready-
cancelledorexpiredreservation is a refusal, and "You can't modify or cancel a CapacityBlock."
The
active-during-commitment path goesactive→cancelling→cancelled, but it requires acancellation quote from
CreateCapacityReservationCancellationQuote, which is out of scope here.The
stateenumeration is thirteen values, and one is undocumentedactive | expired | cancelled | pending | failed | scheduled | payment-pending | payment-failed | assessing | delayed | unsupported | cancelling | unavailableunavailableappears in theValid Valuesline with no prose description anywhere on the page.Nine of the thirteen belong to future-dated reservations or Capacity Blocks, neither of which this
issue asks for, so the seedable set should be the ones an immediate reservation can actually reach —
active,pending,failed,expired,cancelled— with the rest recorded as unmodelled ratherthan silently absent.
failedis the interesting one for criterion 4: "A request can fail due to request parameters thatare not valid, capacity constraints, or instance limit constraints. You can view a failed request for
60 minutes." That is a state, not an error — so a capacity failure has two possible observable
shapes, and which one AWS produces is not stated.
Criterion 4's error codes — all five are real, and two are classified as server errors
All five are on
errors-overview.html. That page's tables have onlyError code | Description— noper-code HTTP status column. Status is given as a class only: client errors "are accompanied by a
400-series HTTP response code", server errors "a 500-series HTTP response code".
InsufficientInstanceCapacityInstanceLimitExceededVcpuLimitExceededUnsupportedRequestLimitExceededTwo of the five name Capacity Reservations explicitly, which is unusually good provenance:
InsufficientInstanceCapacity— "There is not enough capacity to fulfill your request. This errorcan occur if you launch a new instance, restart a stopped instance, create a new Capacity
Reservation, or modify an existing Capacity Reservation."
InstanceLimitExceeded— "This error can occur if you are launching an instance or if you arecreating a Capacity Reservation. Capacity Reservations count towards your On-Demand Instance
limits."
Two things that need deciding explicitly rather than inherited:
InsufficientInstanceCapacitybeing a 500-series code is counter-intuitive for what a consumertreats as a capacity signal, and sonde's whole purpose is distinguishing capacity from account-side
failure. Substrate should answer the documented class, not the intuitive one, and say so — an
emulator that answered 400 would let a consumer's retry logic pass a test it fails in production.
been throttled, you get the following error:
Client.RequestLimitExceeded." — contradicting itsown server-table entry.
CommonErrors.htmldoes not listRequestLimitExceededat all.Exact numeric statuses (500 vs 503) are UNVERIFIED: neither page assigns them.
Also available and arguably better fits than two of the five:
UnsupportedException— "CapacityReservations are not supported for this Region." — and
UnsupportedTenancy. And forClientTokenreuse,
IdempotentParameterMismatch: "The request uses the same client token as a previous, butnon-identical request."
No sample response is published
None of the four pages (
CreateCapacityReservation,DescribeCapacityReservations,CancelCapacityReservation,CapacityReservation) publishes an Examples section or any sample XML.The only verbatim XML on the reference is the generic error envelope. So the success-response element
names come from the member lists above and the
item-wrapper nesting rests on substrate's existingEC2 query-protocol rendering, not on a citation — that should be stated rather than implied.
What this changes about the issue
Nothing in the four criteria is wrong in substance. The corrections are the three wire names, the fact
that create already returns everything describe would (so tag readback needs no second call), that
AvailabilityZoneis not required, that tag enumeration is not one of the twelve documented filters,and that a capacity failure has two documented shapes — a
failedstate and a 500-series error code —where the issue assumes only the second.
docs(ec2): a cancel releases a reservation's available capacity (#891)
scttfrdmn commentedon Sep 17, 2026
Implemented in #1032. Six corrections to what is already on this issue, and the decisions that were
left open above, resolved on the record.
Corrections to my own earlier comments
InstancePlatformpublishes eighteen values, not nineteen. The second comment's list is wrong:there is no
RHEL with HA and SQL Server Web. The eighteen areLinux/UNIX,Red Hat Enterprise Linux,SUSE Linux,Windows,Windows with SQL Server,Windows with SQL Server Enterprise,Windows with SQL Server Standard,Windows with SQL Server Web,Linux with SQL Server Standard,Linux with SQL Server Web,Linux with SQL Server Enterprise,RHEL with SQL Server Standard,RHEL with SQL Server Enterprise,RHEL with SQL Server Web,RHEL with HA,RHEL with HA and SQL Server Standard,RHEL with HA and SQL Server Enterprise,Ubuntu Pro—which is what the first comment says. Only
WindowsandLinuxcarry aWebSQL Server variant;RHEL with HAcarriesStandardandEnterpriseonly. Eighteen is what is enforced.The
statefilter is not restricted to the five documented values. My first comment proposedrefusing an unmodelled
statefilter value. Substrate does not do that: the filter matchesagainst whatever the reservation reports, and a value outside the five simply matches nothing. The
filter's own published enumeration is a statement about what a reservation can be, not a
validation rule, and refusing a well-formed value AWS's own type page publishes would be a
difference from AWS on the strength of a gloss. The narrowing that is enforced is on the
seed — five of the thirteen states are seedable — because seeding a state substrate models no
subsystem behind would publish an observation nothing else in the emulator is consistent with.
capacityReservationId's shape. No published pattern exists, as recorded above, so substratemints
cr-+ 17 lowercase hex through the samerandomHexevery other EC2 ID uses. That isstated in the minter's doc comment as substrate's reading.
The tagging API still does not reach a reservation, and that is now a deliberate deferral rather
than an oversight. My earlier comment said
tagging_plugin.goneeds acapacity-reservationarm and a scanner or cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765's cross-readability rule is broken. That arm is not in feat(ec2): On-Demand Capacity Reservations, with the outcome seedable (#891) #1032 — and
the reason to record is that a reservation's tags are readable through the owning service's own
calls (
DescribeCapacityReservations'tagSet,DescribeTags,CreateTags/DeleteTags), so theThe Resource Groups Tagging API cannot write tags for eleven types: mergeResourceTags has no arm #835 class here is "Resource Groups Tagging cannot see it", not "the tags are unreadable". It is
documented in
docs/services.mdas an unmodelled path and belongs with the nine remaining The Resource Groups Tagging API cannot write tags for eleven types: mergeResourceTags has no arm #835types rather than as a sixteenth one-off.
AvailabilityZoneandAvailabilityZoneIdare neither required nor mutually required. Bothare
Required: Noand the page states no rule on the pair, so a request naming neither isaccepted and reports neither element. A zone name is recorded as given and never validated; a
zone ID must resolve, because it has to be translated to the name the response reports. A pair
naming two different zones answers
InvalidParameterCombination— that one is substrate's reading,since the page does not address the case.
No code exists for cancelling from a non-cancellable state. All three operations carry only the
common-errors boilerplate, the sole state-shaped code in the reference is
InvalidCapacityReservationState.PendingActivation(a Capacity Block that is not active yet), andAWS's own sample tooling pre-checks the state through a describe rather than catching an error.
Substrate answers
IncorrectState/400 as its reading, which is what it already answers forthis shape on a volume and a snapshot.
The open decisions, resolved
EndDateTypeis inferred, not defaulted. AWS publishes noDefault:line and forbids exactlytwo combinations —
limitedwith noEndDate,unlimitedwith one — so anEndDatealone inferslimitedand noEndDateinfersunlimited. Defaulting an absentEndDateTypetounlimitedwould turn a request naming only an
EndDate, which nothing forbids, into the second refusal.StartDateandCommitmentDurationeach answerUnsupported/400. Eight of the thirteenstatevalues exist onlyfor a future-dated reservation or a Capacity Block, and answering
activeto a request for capacitytwo days out would be a false observation carrying nothing to tell a caller the request was not
modelled.
endDate's own sentence, soit is assertable without wall-clock dependence. Only an
activereservation expires: a seededfailedone has already reached a terminal state, and reportingexpiredfor it would lose theoutcome the test seeded.
InstanceCountis enforced at 1–1000 even though the range is prose rather than aValid Range:line, andInstanceCountis not otherwise consumed, because nothing occupies areservation.
POST/DELETE /v1/ec2/capacity-reservation-outcomestakeserrorCodeorstate, refusing arequest naming both — since which shape AWS produces for a given cell is not documented, the choice
belongs to the test. Scoping is (instance type, Availability Zone) with either half omittable, and
the most specific scope carrying a seed decides: cell, then type in any zone, then any type in the
zone, then wildcard. Type before zone is substrate's ordering, because a seed naming a type is the
narrower claim.
IdempotentParameterMismatchis not answered, becauseClientTokenis accepted and inert —there is no idempotency ledger for a mismatch to be detected against. Two identical creates make
two reservations.
UnsupportedException/UnsupportedTenancyare not used.Unsupportedcovers the two shapessubstrate refuses (a future-dated request), and adding a Region- or tenancy-specific code would
require modeling which Regions and tenancies offer a reservation, which substrate does not.
Acceptance criteria
All four are met. Criterion 2's "describe-by-tag" is met client-side, exactly as my third
finding above said it would have to be: no
tag:ortag-keyfilter is published for thisoperation, so a reaper enumerates by reading
tagSetfrom an unfiltered describe (or byDescribeTagson thecr-prefix) and cancels bycreateDate.docs/services.mdrecords that as anunmodelled path rather than leaving it to be discovered.
The
g6.xlargein the repro still needs #896:CreateCapacityReservationdoes not validate theinstance type against the catalog — nothing here refuses an uncatalogued type — so the repro runs
today, but
DescribeInstanceTypesalongside it will not reportg6.xlargeuntil #896 lands.