You can use AWS CLI for AWS billing to get pricing data programmatically for a particular AWS service.
Step 1: Get the service code for the particular AWS service. In this example, we will try to get AWS Simple Storage Service (S3) pricing data.
1 2 3 4 5 6 7 8 9 |
## Get the list of AWS service code in a region aws pricing describe-services \ --region ap-south-1 | jq -r '.Services[] | .ServiceCode' ## Returns ## AmazonEC2 ## AmazonS3 ## AmazonRoute53 ## ... |
Step 2: Get the list of attributes available for that particular service.
1 2 3 4 5 6 7 8 9 10 |
## Get the list of attributes for a given service code aws pricing describe-services \ --service-code AmazonS3 \ --region ap-south-1 | jq -r '.Services[] | .AttributeNames[]' ## Returns ## availability ## durability ## usagetype ## ... |
Step 3: Get pricing data programmatically for a particular AWS service.
1 2 3 4 5 |
## Get all pricing data for a given service code ## This may take some time, as all the pricing data are returned aws pricing get-products \ --service-code AmazonS3 \ --region ap-south-1 |
Warning: Without any filters, the above command will return all the pricing data for that particular AWS service which may take lots of time. It’s recommended to use some filters to narrow down the search result.
Step 4: Filter pricing data based on requirements
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
## You can also filter the data based on your requirements aws pricing get-products \ --service-code AmazonS3 \ --filters "Type=TERM_MATCH,Field=regionCode,Value=ap-south-1" "Type=TERM_MATCH,Field=productFamily,Value=API Request" \ --region ap-south-1 ## Even more filters aws pricing get-products \ --service-code AmazonS3 \ --filters "Type=TERM_MATCH,Field=regionCode,Value=ap-south-1" \ "Type=TERM_MATCH,Field=productFamily,Value=API Request" \ "Type=TERM_MATCH,Field=usagetype,Value=APS3-Requests-Tier1" \ --region ap-south-1 \ --output text ## Returns ##{ ## "PriceList": [{ ## "product": { ## "productFamily": "API Request", ## "attributes": { ## "regionCode": "ap-south-1", ## "servicecode": "AmazonS3", ## "groupDescription": "PUT/COPY/POST or LIST requests", ## "usagetype": "APS3-Requests-Tier1", ## "locationType": "AWS Region", ## "location": "Asia Pacific (Mumbai)", ## "servicename": "Amazon Simple Storage Service", ## "operation": "", ## "group": "S3-API-Tier1" ## }, ## "sku": "UJ844B8DVMQUFJQP" ## }, ## "serviceCode": "AmazonS3", ## "terms": { ## "OnDemand": { ## "UJ844B8DVMQUFJQP.JRTCKXETXF": { ## "priceDimensions": { ## "UJ844B8DVMQUFJQP.JRTCKXETXF.6YS6EN2CT7": { ## "unit": "Requests", ## "endRange": "Inf", ## "description": "$0.005 per 1,000 PUT, COPY, POST, or LIST requests", ## "appliesTo": [], ## "rateCode": "UJ844B8DVMQUFJQP.JRTCKXETXF.6YS6EN2CT7", ## "beginRange": "0", ## "pricePerUnit": { ## "USD": "0.0000050000" ## } ## } ## }, ## "sku": "UJ844B8DVMQUFJQP", ## "effectiveDate": "2021-11-01T00:00:00Z", ## "offerTermCode": "JRTCKXETXF", ## "termAttributes": {} ## } ## } ## }, ## "version": "20211112200916", ## "publicationDate": "2021-11-12T20:09:16Z" ## }], ## "FormatVersion": "aws_v1" ##} |
Very good! Thanks