Skip to content

Instantly share code, notes, and snippets.

@rantoniuk
Created November 5, 2024 11:56
Show Gist options
  • Save rantoniuk/f9e6c05cb91ae3cfbb20fcdb38f34e19 to your computer and use it in GitHub Desktop.
Save rantoniuk/f9e6c05cb91ae3cfbb20fcdb38f34e19 to your computer and use it in GitHub Desktop.

Revisions

  1. rantoniuk created this gist Nov 5, 2024.
    27 changes: 27 additions & 0 deletions aws-cli-hints.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    # Fetch EC2 Instance Prices for a region

    ```sh
    aws --region us-east-1 pricing get-products --service-code AmazonEC2 --filters \
    "Type=TERM_MATCH,Field=capacitystatus,Value=Used" \
    "Type=TERM_MATCH,Field=marketoption,Value=OnDemand" \
    "Type=TERM_MATCH,Field=currentGeneration,Value=Yes" \
    "Type=TERM_MATCH,Field=instanceType,Value=inf1.2xlarge" \
    "Type=TERM_MATCH,Field=location,Value=US West (Oregon)" \
    "Type=TERM_MATCH,Field=operatingSystem,Value=Linux" \
    "Type=TERM_MATCH,Field=marketoption,Value=OnDemand" \
    "Type=TERM_MATCH,Field=servicecode,Value=AmazonEC2" \
    "Type=TERM_MATCH,Field=tenancy,Value=Shared" \
    "Type=TERM_MATCH,Field=operation,Value=RunInstances" \
    | jq -rc '.PriceList[]' | jq -c '[
    .product.attributes.location,
    .product.attributes.instanceType,
    .product.attributes.operatingSystem,
    .product.attributes.memory,
    .product.attributes.physicalProcessor,
    .product.attributes.processorArchitecture,
    .product.attributes.vcpu,
    .terms.OnDemand[].priceDimensions[].description]'
    ["US West (Oregon)","inf1.2xlarge","Linux","16 GiB","Intel Xeon Platinum 8275CL (Cascade Lake)","64-bit","8","$0.362 per On Demand Linux inf1.2xlarge Instance Hour"]
    ```

    In tabular format, add ` | @tsv`