ec2instances.info icon indicating copy to clipboard operation
ec2instances.info copied to clipboard

Viewing instances by region and availability zone (AZ)

Open jocull opened this issue 5 years ago • 9 comments

I believe this change would require API access, since I don't know where it could be scraped from. The information is very tedious to find. Here's the information I have available on how to determine if an instance type is present in a region + AZ:

The best advice we've had is to query the billing API. If cost != null, there are probably instances available

Is this something that would be possible to add? Thanks :slightly_smiling_face:

jocull avatar Jun 12 '19 13:06 jocull

The AZ labels are randomly assigned and account specific, my us-east-1a can be your us-east-1b and someone else's us-east-1c and so on.

We may be able to count the number of AZs and display something like 2/3 if only available in two out of three AZs.

cristim avatar Jun 12 '19 15:06 cristim

Great information to have - I was not aware of that :)

Feel free to close issue in this case or re-open as something more appropriate. Thanks for the response!

jocull avatar Jun 12 '19 15:06 jocull

I don't know, would you find useful such a field indicating the number of AZs having support for each instance type out of the total number of AZs in the region?

cristim avatar Jun 12 '19 18:06 cristim

I think that could still be very useful - most importantly if it's 100% of the AZs or not :smile: I like the example you provided of seeing "2/3 AZs" or something to that effect.

jocull avatar Jun 12 '19 18:06 jocull

I would be interested in contributing to this feature. Can someone point me to where I can get started?

It looks like since this issue was opened AWS has released an API for this info. Here's the corresponding AWS CLI command: https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-type-offerings.html

To list the instance types offered in a Region:

$ aws ec2 describe-instance-type-offerings --region us-east-1
{
  "InstanceTypeOfferings": [
      {
          "InstanceType": "m5.2xlarge",
          "LocationType": "region",
          "Location": "us-east-1"
      },
      {
          "InstanceType": "t3.micro",
          "LocationType": "region",
          "Location": "us-east-1"
      },
      ...
  ]
}

To list the instance types offered in all availability zones for a given account and region:

$ aws ec2 describe-instance-type-offerings --location-type availability-zone --region us-east-1
{
    "InstanceTypeOfferings": [
        {
            "InstanceType": "t4g.medium",
            "LocationType": "availability-zone",
            "Location": "us-east-1a"
        },
        {
            "InstanceType": "r5n.2xlarge",
            "LocationType": "availability-zone",
            "Location": "us-east-1d"
        },
        {
            "InstanceType": "x1e.2xlarge",
            "LocationType": "availability-zone",
            "Location": "us-east-1d"
        },
        {
            "InstanceType": "m5.24xlarge",
            "LocationType": "availability-zone",
            "Location": "us-east-1b"
        },
        ...
    ]
}

Since the Locations returned are specific to a given AWS account, we would also need to map those to the corresponding availability zone ids which are not specific to a given AWS account. This is the ZoneId in the following response:

$ aws ec2 describe-availability-zones --region us-east-1
{
    "AvailabilityZones": [
        {
            "State": "available",
            "OptInStatus": "opt-in-not-required",
            "Messages": [],
            "RegionName": "us-east-1",
            "ZoneName": "us-east-1a",
            "ZoneId": "use1-az1",
            "GroupName": "us-east-1",
            "NetworkBorderGroup": "us-east-1",
            "ZoneType": "availability-zone"
        },
        {
            "State": "available",
            "OptInStatus": "opt-in-not-required",
            "Messages": [],
            "RegionName": "us-east-1",
            "ZoneName": "us-east-1b",
            "ZoneId": "use1-az2",
            "GroupName": "us-east-1",
            "NetworkBorderGroup": "us-east-1",
            "ZoneType": "availability-zone"
        },
        ...
    ]
}

So we should be able to publish something along the lines of:

Name API Name Supported AZs
T3 Nano t3.nano use1-az1, use1-az2, use1-az4, use1-az5, use1-az6
M5 General Purpose Large m5.large use1-az1, use1-az2, use1-az3
C5 High-CPU 9xlarge c5.9xlarge use1-az1, use1-az2, use1-az3, use1-az4, use1-az5, use1-az6

burck1 avatar Jan 27 '21 18:01 burck1

The AZ aliases you have listed above are more deterministic now. The AWS Resource Access Manager (RAM) lists what "your" account's AZs are vs. the deterministic AZ identifiers you see listed here above 😄

jocull avatar Jan 27 '21 18:01 jocull

I've submitted a PR #544 with some screenshots.

burck1 avatar Feb 05 '21 04:02 burck1

Can the site sort by cost per region?

jxu avatar Jan 09 '22 06:01 jxu

@jxu currently it is scoped to a region but this would be an interesting addition. Are you trying to find the cheapest instance in a particular region? It seems like us-east-1 will always be cheapest.

EverettBerry avatar May 14 '22 18:05 EverettBerry