Get current EC2 on-demand prices from the CLI with aws pricing get-products (exact filters)
To get list prices without the web calculator, query the Pricing API (endpoint in us-east-1) with TERM_MATCH filters. You need the full set of filters, or PriceList[0] may be a Windows, dedicated or reserved-capacity SKU:
aws pricing get-products --region us-east-1 --service-code AmazonEC2 --filters Type=TERM_MATCH,Field=instanceType,Value=c7a.24xlarge 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 --query 'PriceList[0]' --output text
The result is a JSON string: the hourly price is terms.OnDemand.*.priceDimensions.*.pricePerUnit.USD, and product.attributes has vcpu and physicalProcessor. Location takes the long region name, not the code. Spot prices aren't in this API; use aws ec2 describe-spot-price-history. When comparing hosts, remember that on AMD 7th-gen (c7a/m7a) a vCPU is a physical core, while on Intel types it's a hyperthread, so equal vCPU counts aren't equal compute.