Skip to content

GetProducts

Source: src/AWS/Pricing/GetProducts.ts

Runtime binding for pricing:GetProducts — query the AWS Price List API for all products that match the filter criteria.

The Price List Query API is a global, data-only service with no resource to manage: the binding takes no arguments and grants the function pricing:GetProducts (the action has no resource-level IAM). Calls are pinned to us-east-1, the region that serves the Price List API, regardless of where the function runs. Each PriceList entry is a JSON string describing one product and its terms. Provide the implementation with Effect.provide(AWS.Pricing.GetProductsHttp).

// init
const getProducts = yield* AWS.Pricing.GetProducts();
// runtime
const result = yield* getProducts({
ServiceCode: "AmazonEC2",
Filters: [
{ Type: "TERM_MATCH", Field: "instanceType", Value: "t3.micro" },
{ Type: "TERM_MATCH", Field: "location", Value: "US East (N. Virginia)" },
{ Type: "TERM_MATCH", Field: "operatingSystem", Value: "Linux" },
],
MaxResults: 10,
});
const products = (result.PriceList ?? []).map((item) => JSON.parse(item));