aws-pricing
Get AWS service pricing information
TLDR
List service codes of a specific region
List attributes for a given service code in a specific region
Print pricing information for a service code in a specific region
List values for a specific attribute for a service code in a specific region
Print pricing information for a service code using filters for instance type and location
SYNOPSIS
aws pricing get-products [--service-code value] [--filters value [value...]] [--format-version value] [--region value] [--output value] [--query value] [global-options]
PARAMETERS
--service-code value
Specifies the service for which to retrieve pricing data (e.g., AmazonEC2, AmazonS3).
--filters value [value...]
A list of filters to narrow down the products, specified as 'Field=fieldName,Type=TERM_MATCH,Value=fieldValue'.
--format-version value
The format version of the pricing data response (e.g., aws_v1).
--region value
Specifies the AWS region to connect to for the pricing service API endpoint.
--output value
Specifies the output format, such as json, text, or yaml.
--query value
A JMESPath query to filter and transform the command's JSON output.
DESCRIPTION
The command line utility for accessing AWS pricing information is primarily handled by the aws pricing service within the AWS Command Line Interface (CLI). Specifically, the aws pricing get-products command enables users to programmatically retrieve detailed pricing data for various AWS services and their associated products directly from the AWS Price List API. This command is not a standalone Linux utility but rather a part of the official AWS CLI package, which must be installed and configured.
It provides comprehensive attributes such as service codes (e.g., AmazonEC2, AmazonS3), product families, specific instance types, regions, and their corresponding price dimensions (e.g., On-Demand, Reserved Instance, Savings Plan rates). This functionality is invaluable for developers, system administrators, and financial analysts for automating cost analysis, integrating real-time pricing into custom applications, forecasting budgets, and making informed decisions about resource provisioning based on current AWS costs.
CAVEATS
The command aws-pricing as a standalone Linux command does not exist. The functionalities described pertain to the aws pricing service within the AWS CLI. Users must have the AWS CLI installed and configured with appropriate AWS credentials. The output from aws pricing get-products can be extremely verbose and complex, often requiring external tools like jq for effective parsing and data extraction. There are API rate limits that apply to the Pricing API, so excessive calls may be throttled. Pricing data might have a slight latency compared to real-time changes on the AWS console.
PARSING OUTPUT
The JSON output from aws pricing get-products contains nested structures for products and their price dimensions. Effectively extracting specific pricing points, such as the On-Demand hourly rate for a particular instance type in a given region, typically requires piping the command's output to a JSON processing tool like jq. For example, filtering for Linux EC2 instances might involve complex jq queries to navigate through 'product', 'attributes', and 'terms' sections of the JSON response.
COMMON USE CASES
Beyond simple lookups, this command is critical for building custom cloud cost calculators, creating scripts that automatically monitor and alert on price changes for specific services, and validating billing information against published prices. It also plays a role in implementing cost-aware auto-scaling solutions or provisioning strategies where the most cost-effective resource configuration is dynamically selected based on current pricing data.
HISTORY
Before the advent of programmatic APIs, AWS pricing data was primarily available through web pages or PDF documents, making automated analysis challenging. AWS introduced the Price List API to address this, providing a structured, queryable data source. The AWS CLI integrated this API, offering commands like aws pricing get-products as a user-friendly interface. This evolution has significantly empowered developers and finance teams to automate cost management, track price changes, and build sophisticated tools for AWS resource optimization, adapting to the dynamic nature of AWS pricing models.