A GetProducts filter read only the product's attributes, under the exact
spelling of the field, so `productFamily` (held beside the attributes) and
`serviceCode` (the attribute is `servicecode`) matched nothing.
A filter's field is now one of the product's attributes, or else a member
the product holds beside them, as productFamily is. No field is named in
the code. The API reference says "Matching isn't case sensitive for any
filter type", so fields and values match without regard to case under
every filter type, and an exact regionCode in any case picks its Region.
With FLOCI_SERVICES_PRICING_AWS_PRICE_LIST=true (off by default),
GetProducts answers from the public files of AWS's Price List Bulk API
instead of the bundled snapshot. The service is looked up in AWS's offer
index. An exact regionCode filter reads the Region's current file, named
by the service's region index; without one, the current file for every
Region, named by the version index, is read. Each file is downloaded once
into <persistent-path>/pricing, and again when AWS publishes a new
version. It is read as a stream that keeps only the products of the page,
in the file's order, with their terms. An index is reused while AWS's
response says it is fresh (Cache-Control max-age less Age), and is
otherwise asked for again with its ETag, so an unchanged index comes
back as 304 without a body. A connection that takes 10 s to open, or
stops sending for 10 s, fails the request. The offer index address is
the setting FLOCI_SERVICES_PRICING_AWS_PRICE_LIST_URL.
A page holds at most MaxResults products, or the most the operation
models when the request names none. Pricing's request constraints come
from botocore through tools/aws/regen_pricing_shapes.py, and a request
that breaks one is refused in the words AWS answers with: MaxResults out
of range, more than 50 Filters, a filter's Field or Value outside 1 to
1024 characters, a missing member, or a filter Type outside the modeled
set. The shared request check now words a list of structures, each
element's members at its position counting from 1
(filters.1.member.type), as AWS does. A missing required member is
InvalidParameterException, the only validation error Pricing models,
instead of ValidationException. ListPriceLists holds a timestamp, which
the shared check does not word yet, so only its MaxResults is checked.
A token names the
file version it was read from: a token from a version AWS has replaced
has expired (ExpiredNextTokenException), and a token no page wrote is
answered as AWS answers it (InvalidNextTokenException).
Cost Explorer reads every product of a Region, not only the first 1000,
in one pass: the file is read once for where each SKU's terms are, then
for the products, reading a match's terms from their place. AWS lists
one product per operating system under a usage type, so a usage line is
priced at the product for its operation, as the BCM Pricing Calculator
matches it. Rates read from a version of AWS's file are kept until AWS
publishes another. A usage line with no usage costs nothing at any
rate, so no rate is looked up for it, and no Region's file is read for
a service nothing used.
DescribeServices, GetAttributeValues, ListPriceLists and
GetPriceListFileUrl keep answering from the snapshot.
Closes#8339
Implements the `AWSPriceListService.*` JSON 1.1 surface backed by a
bundled static snapshot on the classpath. Covers the five public
operations: `DescribeServices`, `GetAttributeValues`, `GetProducts`,
`ListPriceLists`, and `GetPriceListFileUrl`, with pagination (Base64
offset tokens) and the array-of-JSON-strings `PriceList` shape the
real AWS SDKs expect.
Rationale: Floci today cannot back FinOps tooling (cost detection,
budget guards, CUR parsers, etc.) because the billing APIs are
absent. Pricing is the stateless prerequisite for the Cost Explorer
and CUR services that follow — cost lines are synthesized as
`resource state x pricing snapshot`, so the snapshot data path is the
foundation.
Snapshot layout on the classpath (and mirrored on the filesystem
when `FLOCI_SERVICES_PRICING_SNAPSHOT_PATH` is set):
pricing-snapshots/services.json
pricing-snapshots/attribute-values/<ServiceCode>/<Attr>.json
pricing-snapshots/products/<ServiceCode>/<Region>.json
pricing-snapshots/price-lists/<ServiceCode>.json
The bundled snapshot is intentionally minimal — `AmazonEC2`,
`AmazonS3`, and `AWSLambda` in `us-east-1` — to exercise SDK parsing
and filter logic without bloating the image. Users needing broader
coverage point the override env var at a full snapshot generated
from the AWS Price List bulk API.
Wiring follows the existing JSON 1.1 stateless pattern (Textract,
Secrets Manager): descriptor in `ResolvedServiceCatalog`, handler
injected into `AwsJson11Controller`, service config on
`EmulatorConfig.ServicesConfig`. No new protocol, no changes to
existing services, no new runtime dependencies.
Tests: `PricingIntegrationTest` covers all five operations via
RestAssured JSON 1.1 wire-format assertions, including validation
errors, unknown-service errors, filter matching, and pagination
tokens (17 tests, all green).
Refs: https://github.com/orgs/floci-io/discussions/791