# Pricing (AWS Price List Service) **Protocol:** JSON 1.1 **Header:** `X-Amz-Target: AWSPriceListService.` **Endpoint prefix:** `api.pricing` Floci emulates the AWS Price List Service backed by a bundled static snapshot. Responses match the real AWS wire format so AWS SDK and CLI clients accept the reply without modification. The bundled snapshot covers a minimal, representative set of services and regions; for broader coverage, point Floci at your own snapshot with `FLOCI_SERVICES_PRICING_SNAPSHOT_PATH`. ## Supported Operations | Operation | Notes | |-----------|-------| | `DescribeServices` | Lists bundled services and their queryable attribute names | | `GetAttributeValues` | Returns the set of values a given attribute can take | | `GetProducts` | Returns `PriceList` as an array of JSON-encoded product-offer strings (matches AWS format) | | `ListPriceLists` | Lists available price-list ARNs filtered by service, currency, and optional region | | `GetPriceListFileUrl` | Returns a stub HTTPS URL; useful for code paths that validate URL presence | Pagination is supported on all list operations via `NextToken` + `MaxResults`. A request is checked against the constraints in the operation's AWS model, such as `MaxResults` from 1 to 100, at most 50 `Filters`, and a filter's `Field` and `Value` of at most 1024 characters, and a request that breaks one is refused with `InvalidParameterException`, as AWS refuses it. ## Bundled Snapshot The default snapshot on the classpath covers: | ServiceCode | Regions | Notes | |-------------|---------|-------| | `AmazonEC2` | `us-east-1` (Linux/Shared tenancy, 3 instance types) | `t3.micro`, `m5.large`, `c5.large` | | `AmazonS3` | `us-east-1` (Standard storage) | | | `AWSLambda` | `us-east-1` (Requests) | | The snapshot is intentionally minimal — enough to exercise SDK parsing and filter logic — not a comprehensive price database. ## Configuration | Variable | Default | Description | |---|---|---| | `FLOCI_SERVICES_PRICING_ENABLED` | `true` | Enable or disable the service | | `FLOCI_SERVICES_PRICING_SNAPSHOT_PATH` | *(unset)* | Filesystem directory overriding the bundled snapshot | | `FLOCI_SERVICES_PRICING_AWS_PRICE_LIST` | `false` | Answer `GetProducts` from AWS's public price list files instead of the snapshot | | `FLOCI_SERVICES_PRICING_AWS_PRICE_LIST_URL` | `https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/index.json` | The offer index of AWS's price list files | ### Reading AWS's price list files With `FLOCI_SERVICES_PRICING_AWS_PRICE_LIST=true`, `GetProducts` answers from the files of the [AWS Price List Bulk API](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/using-the-aws-price-list-bulk-api.html), which need no credentials. Floci looks the service up in AWS's offer index, so every service AWS publishes prices for can be queried, then reads: - the current file for one Region, from the service's region index, when the request has a `TERM_MATCH` or `EQUALS` filter on `regionCode`; - the current file for every Region, from the service's version index, otherwise. Each file is downloaded once into `/pricing` and downloaded again when AWS publishes a new version, which replaces the old copy. The indexes are reused while AWS's response says they are fresh (its `Cache-Control` max-age), and are otherwise asked for again with their `ETag`, so an unchanged index is not downloaded again. Floci needs network access to AWS while the setting is on. A connection that takes more than 10 seconds to open, or stops sending for 10 seconds, fails the request. Files can be large: the EC2 file for `us-east-1` is about 485 MB, and the EC2 file for every Region about 9.2 GB, so add a `regionCode` filter to EC2 queries. The products come back as AWS lists them, in the order of the file, with their terms of each type. A page holds at most `MaxResults` products, or 100, the most `GetProducts` allows, when the request names none. A `NextToken` names the file version it was read from: once AWS publishes a new version, the token has expired (`ExpiredNextTokenException`) and the query starts again without it. Cost Explorer and the BCM Pricing Calculator read their rates through the Pricing service, so they read AWS's files too while the setting is on. Cost Explorer reads every product of a Region in one pass over the file, and keeps the rates until AWS publishes a new version of it. AWS lists one product per operating system under the same usage type, so a usage line is priced at the product for its operation, such as `RunInstances` for Linux. `DescribeServices`, `GetAttributeValues`, `ListPriceLists` and `GetPriceListFileUrl` keep answering from the snapshot. ### Snapshot directory layout When `FLOCI_SERVICES_PRICING_SNAPSHOT_PATH` is set, Floci reads files in this layout (falling back to the classpath entry for any file that does not exist): ``` / services.json # [ { "ServiceCode": "...", "AttributeNames": [...] } ] attribute-values//.json # [ { "Value": "..." } ] products//.json # [ { "product": {...}, "terms": {...}, ... } ] price-lists/.json # [ { "PriceListArn": "...", "RegionCode": "...", ... } ] ``` Each product entry is stored as a JSON object; Floci re-serializes it into the array-of-JSON-strings shape AWS returns. Drop in a full snapshot generated from the [AWS Price List Bulk API](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html) when the bundled fixtures are insufficient. ## Examples ```bash export AWS_ENDPOINT_URL=http://localhost:4566 export AWS_DEFAULT_REGION=us-east-1 export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test aws pricing describe-services --service-code AmazonEC2 aws pricing get-attribute-values \ --service-code AmazonEC2 --attribute-name instanceType aws pricing get-products \ --service-code AmazonEC2 \ --filters 'Type=TERM_MATCH,Field=instanceType,Value=t3.micro' \ 'Type=TERM_MATCH,Field=regionCode,Value=us-east-1' aws pricing list-price-lists \ --service-code AmazonEC2 \ --effective-date 2026-01-01T00:00:00Z \ --currency-code USD ``` ```python import boto3 client = boto3.client( "pricing", endpoint_url="http://localhost:4566", region_name="us-east-1", ) resp = client.get_products( ServiceCode="AmazonEC2", Filters=[ {"Type": "TERM_MATCH", "Field": "instanceType", "Value": "t3.micro"}, {"Type": "TERM_MATCH", "Field": "regionCode", "Value": "us-east-1"}, ], ) for item in resp["PriceList"]: # AWS returns PriceList as an array of JSON strings; parse each separately. import json print(json.loads(item)["product"]["sku"]) ``` ## Out of Scope - Bulk download of full regional price lists (`GetPriceListFileUrl` returns a stub URL; the file is not served). - Volume discounts, Savings Plans, or Reserved Instance pricing terms beyond what the bundled snapshot declares. - Automatic refresh of the snapshot from upstream AWS. To read current prices, turn on `FLOCI_SERVICES_PRICING_AWS_PRICE_LIST`.