Skip to content

feat(pricing): an AmazonEC2 offer corpus for GetProducts (#894) - #1034

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/pricing-ec2-corpus-894
Sep 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/pricing-ec2-corpus-894

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #894.

GetProducts answered NotFoundException for ServiceCode=AmazonEC2, so a consumer that reads
on-demand instance rates at runtime to cost its own usage could only be tested against a
hand-maintained table — the failure mode the Price List emulation exists to remove, where the original
reporter's table was 10× wrong on one S3 rate and 21× wrong on another.

What ships

32 EC2 SKUs extracted from the live us-east-1, us-west-2 and eu-west-1 offer files (version
20260910195514): nine instance types per Region (t3.micro, m5.xlarge, g4dn.xlarge,
g5.2xlarge, g6.xlarge, inf2.xlarge, p4d.24xlarge, p5.48xlarge, trn1.32xlarge), seven
m5.xlarge variants each one attribute from the nominal row, and the free-tier pseudo-product. The
issue's exact query — the seven documented filters, then
terms.OnDemand.*.priceDimensions.*.pricePerUnit.USD — now returns one rate for all nine types in the
two US Regions and for six of the nine in eu-west-1.

No rate is derived from another rate, and the data is why:

  • eu-west-1 is a per-family premium over us-east-1, not one Region multiplier: p4d ≈1.080×,
    inf2 exactly 1.250×, m5 ≈1.115×, t3 ≈1.096×. A single multiplier would be wrong by up to 15%.
  • us-west-2 matches us-east-1 on every rate here except p4d.24xlarge — 21.9576420000
    against 21.9576400000.
  • eu-west-1 publishes no g6, p5 or trn1 compute product at all, so a derived rate would
    invent one and a consumer would price a Region it cannot launch in.

The extraction streams the three 480 MB files rather than transcribing them, and every rate
independently reproduces the measured notes. The one structural liberty: an instance type's physical
attributes are held once per type rather than per Region, which was verified by measurement — only
location, regionCode and usagetype vary by Region for a given type.

Three traps found in the data rather than predicted

  1. The seven-filter recipe is not sufficient. With all seven applied, a Windows m5.xlarge in
    us-east-1 returns three SKUs, sharing one usagetype and differing only in licenseModel and
    operation — $0.376 with a license, $0.192 without one, $0.192 BYOL. licenseModel is an eighth
    discriminator, and a caller taking PriceList[0] picks one arbitrarily.
  2. usagetype is not 1:1 with a SKU in EC2's file — four corpus SKUs share BoxUsage:m5.xlarge.
    The S3 corpus's own preamble calls it "reliably present and 1:1"; that is an S3 accident, not a
    Price List rule, and it is now scoped to S3 in both the fixture and docs/services.md.
  3. marketoption alone separates a $55.04 p5.48xlarge from a $0.00 Capacity Block one, so a
    query that omits it can report a free p5 — the worst failure shape for a cost path, because it looks
    like a successful lookup.

Also reproduced: capacitystatus and tenancy change the usagetype token (UnusedBox:,
DedicatedUsage:) rather than only the price; the usagetype Region prefix is not derivable from the
Region code (us-east-1 none, us-west-2 USW2-, eu-west-1 the legacy EU-); and Compute Instance excludes bare metal, a separate productFamily.

Shape changes

The free-tier product falsifies five invariants a parser written against the nominal rows would
assume — no instanceType on a Compute Instance product, endRange "750" rather than "Inf", an
offerTermCode (A429C66SYZ) that is not the global on-demand code, a non-empty termAttributes, and
an appliesTo listing 170 SKUs where every other on-demand dimension's is empty. Carrying it needed
two new pricingCorpusEntry fields, offerTermCode and termAttributes, each defaulting to what AWS
emits everywhere else.

A PriceList document now reports its own service's offer-file revision in version and
publicationDate rather than one global pair, because EC2 and S3 publish on their own schedules.

DescribeServices reports AmazonEC2 ahead of AmazonS3 with 41 attribute names that are exactly the
union of what the corpus SKUs carry, preserving the registry's invariant that every advertised
attribute is usable as a filter.

What this is not

Tests

Twelve new tests, every one through a real wire call to GetProducts: the Linux recipe isolates one
SKU at 0.8048000000; the Windows recipe returns three with three distinct licenseModel values, and
adding licenseModel narrows to one; p5.48xlarge without marketoption returns both 55.0400000000
and 0.0000000000; eu-west-1 returns nothing for g6/p5/trn1 while us-east-1 returns a rate
and eu-west-1 m5.xlarge returns 0.2140000000; the three usagetype Region prefixes; the
p4d.24xlarge divergence with m5.xlarge as the counter-case; the Dedicated/UnusedCapacityReservation/SQL Std
variants and their usagetype tokens; the instancesku cross-reference resolving to the Used SKU; the
free-tier product's five falsified invariants; a regionCode filter never selecting the free-tier SKU;
per-service offer revisions differing; and ServiceCode scoping, so the EC2 slice cannot leak into an
S3 query. TestPricingDescribeServices now walks every advertised service rather than assuming
Services[0] is AmazonS3.

Verification

Nine-command gate, all green: gofmt/go build/go vet, golangci-lint run ./... (0 issues),
make test, GOTOOLCHAIN=go1.26.6 make test, GOTOOLCHAIN=go1.26.6 make coverage
(85.1% emulator / 84.6% total, holding the baseline), make docs-reference docs-reference-check docs-versions authz-reference-check, npm --prefix docs run build, and the e2e suite.

GetProducts answered NotFoundException for ServiceCode=AmazonEC2, so a consumer
that reads on-demand instance rates at runtime to cost its own usage could only be
tested against a hand-maintained table — the failure mode the Price List emulation
exists to remove, where the original reporter's table was 10x wrong on one S3 rate
and 21x wrong on another.

Bundle 32 EC2 SKUs extracted from the live us-east-1, us-west-2 and eu-west-1 offer
files: nine instance types per Region, seven m5.xlarge variants each one attribute
from the nominal row, and the free-tier pseudo-product. No rate is derived from
another rate, and the data says why: eu-west-1 is a per-family premium rather than
one Region multiplier (p4d ~1.080x, inf2 exactly 1.250x, m5 ~1.115x, t3 ~1.096x),
us-west-2 matches us-east-1 on every rate here except p4d.24xlarge (21.9576420000
against 21.9576400000), and eu-west-1 publishes no g6, p5 or trn1 compute product at
all. A derived rate would invent one, and a consumer would price a Region it cannot
launch in.

Three traps were found in the data rather than predicted. The documented
seven-filter recipe for "one on-demand rate" returns three SKUs for a Windows
m5.xlarge, sharing one usagetype and differing only in licenseModel and operation
($0.376 with a license, $0.192 without one, $0.192 BYOL), so licenseModel is an
eighth discriminator. usagetype is not 1:1 with a SKU in EC2's file — four corpus
SKUs share BoxUsage:m5.xlarge — which makes the S3 corpus's "reliably present and
1:1" an S3 accident rather than a Price List rule, now scoped to S3 in both the
fixture and the docs. And marketoption alone separates a $55.04 p5.48xlarge from a
$0.00 Capacity Block one, so a query omitting it can report a free p5.

The free-tier product is carried because it falsifies five invariants a parser
written against the nominal rows would assume: no instanceType on a Compute Instance
product, endRange "750" rather than "Inf", an offerTermCode that is not the global
on-demand code, a non-empty termAttributes, and an appliesTo listing 170 SKUs where
every other on-demand dimension's is empty. Its regionCode is the empty string, so a
Region-scoped query never selects it. Carrying it needed two new pricingCorpusEntry
fields, offerTermCode and termAttributes, each defaulting to what AWS emits
everywhere else.

A PriceList document now reports its own service's offer-file revision in version
and publicationDate rather than one global pair, because EC2 and S3 publish on their
own schedules and the real API's strings differ accordingly.

Two boundaries are stated rather than blurred: the corpus is not EC2's instance-type
catalog (#896 — a rate here is not a claim the type can be launched), and it is not
exhaustive, so an absent type's empty PriceList reads the same as a Region that
genuinely does not publish it.
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit ddbd7cc into main Sep 17, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/pricing-ec2-corpus-894 branch September 17, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pricing: GetProducts has no AmazonEC2 offer data (corpus is AmazonS3 only)

1 participant