本文介绍了列出区域或可用区中的所有 EC2 实例类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然似乎有几种方法可以将一些 AWSCLI 命令输出和过滤到此列表中,但有人有一种很好且简单的方法来列出特定区域的所有 EC2 实例类型吗?

While there appear to be a few ways to output and filter some AWSCLI commands into this list, does someone have a nice+easy way to list all EC2 instance types for a specific region?

或者该列表可能发布在某个存储桶中的 .json 文件中,由 AWS 维护?

Or perhaps that list is published in a .json file up in a bucket someplace, maintained by AWS?

我只是在寻找这种输出:

I'm simply looking for this sort of output:

t1.micro
t2.nano
t2.micro
t2.small
...

推荐答案

看来至少有一种编程方式是查询 AWS Pricing API:

Well it seems that at least one programmatic way to do this is to query the AWS Pricing API:

#!/bin/bash

curl https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json | jq -r '.products[].attributes["instanceType"]' | sort -u | grep '.'

这里有一个要点,以防将来进行调整:https://gist.github.com/nmagee/b096e6fadf9ac336da7ffdada43f656a

A gist for this is here, in case of future tweaks:https://gist.github.com/nmagee/b096e6fadf9ac336da7ffdada43f656a

缺少的是按 AWS 区域分组/指定,这可能是一个重要区别——并​​非每个区域都提供所有实例类型产品.

What this is lacking is grouping/specifying by AWS Region, which can be an important distinction -- not every region has all instance type offerings.

这篇关于列出区域或可用区中的所有 EC2 实例类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 05:25