determine the price of spot t4g.large in us-east-1
$ aws ec2 describe-spot-price-history \ --region us-east-1 \ --instance-types t4g.large \ --product-descriptions "Linux/UNIX" \ --start-time "$(date -u -d '2 hours ago' +%FT%TZ)" \ --max-items 20 \ --query "SpotPriceHistory[].[AvailabilityZone,SpotPrice,Timestamp]" \ --output table --------------------------------------------------------- | DescribeSpotPriceHistory | +-------------+-----------+-----------------------------+ | us-east-1b | 0.028200 | 2026-01-30T20:02:43+00:00 | | us-east-1c | 0.029800 | 2026-01-30T19:17:41+00:00 | | us-east-1d | 0.031500 | 2026-01-30T19:17:41+00:00 | | us-east-1a | 0.029500 | 2026-01-30T15:47:42+00:00 | | us-east-1b | 0.028100 | 2026-01-30T15:34:11+00:00 | | us-east-1d | 0.031700 | 2026-01-30T11:35:15+00:00 | | us-east-1f | 0.033000 | 2026-01-30T09:47:55+00:00 | | us-east-1c | 0.029900 | 2026-01-30T00:02:41+00:00 | +-------------+-----------+-----------------------------+
determining the price of on-demand for the same
$ aws pricing get-products \ --region us-east-1 \ --service-code AmazonEC2 \ --filters \ Type=TERM_MATCH,Field=instanceType,Value=t4g.large \ Type=TERM_MATCH,Field=location,Value="US East (N. Virginia)" \ Type=TERM_MATCH,Field=operatingSystem,Value=Linux \ Type=TERM_MATCH,Field=tenancy,Value=Shared \ Type=TERM_MATCH,Field=preInstalledSw,Value=NA \ Type=TERM_MATCH,Field=capacitystatus,Value=Used \ --max-results 1 \ --output json \ | jq -r ' .PriceList[0] | fromjson | .terms.OnDemand | to_entries[0].value.priceDimensions | to_entries[0].value.pricePerUnit.USD ' 0.0672000000
