获取可用AWS产品列表的编程方式?

时间:2017-06-21 11:26:56

标签: amazon-web-services boto3

似乎有大约一百种AWS产品可供使用。获得权威列表的唯一方法是look on the web

是否有任何API可以为我提供所有当前可用AWS产品的列表,最好是每个产品的一些元数据(产品标题,描述,可用的区域和边缘位置等)?< / p>

4 个答案:

答案 0 :(得分:1)

一种方法是使用aws命令行界面获取可用服务列表,并使用相应的describelist命令获取已配置/可用的服务。

答案 1 :(得分:1)

Python API库Boto3Botocore。我提供了一个代码片段来列出服务。你必须查看文档以获得你想要的其他信息。

>>> import boto3
>>> session = boto3.Session()
>>> session.get_available_services()
['acm', 'apigateway', 'application-autoscaling', 'appstream', 'autoscaling', 'batch', 'budgets', 'clouddirectory', 'cloudformation', 'cloudfront', 'cloudhsm', 'cloudsearch', 'cloudsearchdomain', 'cloudtrail', 'cloudwatch', 'codebuild', 'codecommit', 'codedeploy', 'codepipeline', 'cognito-identity', 'cognito-idp', 'cognito-sync', 'config', 'cur', 'datapipeline', 'devicefarm', 'directconnect', 'discovery', 'dms', 'ds', 'dynamodb', 'dynamodbstreams', 'ec2', 'ecr', 'ecs', 'efs', 'elasticache', 'elasticbeanstalk', 'elastictranscoder', 'elb', 'elbv2', 'emr', 'es', 'events', 'firehose', 'gamelift', 'glacier', 'health', 'iam', 'importexport', 'inspector', 'iot', 'iot-data', 'kinesis', 'kinesisanalytics', 'kms', 'lambda', 'lex-runtime', 'lightsail', 'logs', 'machinelearning', 'marketplacecommerceanalytics', 'meteringmarketplace', 'opsworks', 'opsworkscm', 'pinpoint', 'polly', 'rds', 'redshift', 'rekognition', 'route53', 'route53domains', 's3', 'sdb', 'servicecatalog', 'ses', 'shield', 'sms', 'snowball', 'sns', 'sqs', 'ssm', 'stepfunctions', 'storagegateway', 'sts', 'support', 'swf', 'waf', 'waf-regional', 'workspaces', 'xray']

>>> for item, service in (enumerate(session.get_available_services(), 1)):
...   print item, service
...
1 acm
2 apigateway
3 application-autoscaling
4 appstream
5 autoscaling
6 batch
7 budgets
8 clouddirectory
9 cloudformation
10 cloudfront
11 cloudhsm
12 cloudsearch
13 cloudsearchdomain
14 cloudtrail
15 cloudwatch
16 codebuild
17 codecommit
18 codedeploy
19 codepipeline
20 cognito-identity
21 cognito-idp
22 cognito-sync
23 config
24 cur
25 datapipeline
26 devicefarm
27 directconnect
28 discovery
29 dms
30 ds
31 dynamodb
32 dynamodbstreams
33 ec2
34 ecr
35 ecs
36 efs
37 elasticache
38 elasticbeanstalk
39 elastictranscoder
40 elb
41 elbv2
42 emr
43 es
44 events
45 firehose
46 gamelift
47 glacier
48 health
49 iam
50 importexport
51 inspector
52 iot
53 iot-data
54 kinesis
55 kinesisanalytics
56 kms
57 lambda
58 lex-runtime
59 lightsail
60 logs
61 machinelearning
62 marketplacecommerceanalytics
63 meteringmarketplace
64 opsworks
65 opsworkscm
66 pinpoint
67 polly
68 rds
69 redshift
70 rekognition
71 route53
72 route53domains
73 s3
74 sdb
75 servicecatalog
76 ses
77 shield
78 sms
79 snowball
80 sns
81 sqs
82 ssm
83 stepfunctions
84 storagegateway
85 sts
86 support
87 swf
88 waf
89 waf-regional
90 workspaces
91 xray

答案 2 :(得分:0)

有趣的是,我怀疑这些信息的最完整来源(非常精细的细节)是Price List API。

例如:

要查找所有可用商品文件的列表,请下载商品索引文件。请注意它提供的内容:

  

提供索引文件 - 列出支持的AWS服务的JSON文件,以及每个商品文件的URL,您可以在其中下载定价详细信息。该文件还包括有关商品索引文件本身的元数据,服务商品文件的URL以及区域商品索引文件的URL。

     

http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html

反过来,各个服务文件会详细列出所有可能服务元素的所有定价信息。

一个特别有用的例子是EC2的情况,这里提供了定价数据中的各种实例类型属性 - 您可以找到详细的处理器型号,时钟速度,CPU数量等信息。

答案 3 :(得分:0)

通过从/ products页面抓取html来获取数据的快速perl脚本。这将获得一个不错的json数据集。

#!/usr/bin/perl 
# 
#This script is intended to simply piece togather a json file for available JSON services. 
#

use v5.16.1;
use strict;
use warnings;
use JSON;

my ($category,%data, %opts, $marker);
my $count = 1;

my @foo = `curl https://aws.amazon.com/products/`;

foreach my $line (@foo) {
  if ($line =~ /<h6> <a href.*?>(.*?)<i class/) {
    $category = $1;
    next;
  }

  if ($line =~ /^\s*<a href="https:\/\/aws.amazon.com\/.*?\/?(.*?)\/\?nc2.*?>(.*?)<span>(.*?)<\/span/) {
    $data{category}{$category}{services}{$1}{name} = $2;
    $data{category}{$category}{services}{$1}{description} = $3;
  }
}

my $json = encode_json \%data;
say $json;
exit;

确保已安装perl JSON模块。用法:

script_name.pl | python -m json.tool > your_json_file.json

示例输出:

"Storage": {
    "services": {
        "ebs": {
            "description": "EC2 Block Storage Volumes",
            "name": "Amazon Elastic Block Store (EBS)"
        },
        "efs": {
            "description": "Fully Managed File System for EC2",
            "name": "Amazon Elastic File System (EFS)"
        },
        "glacier": {
            "description": "Low-cost Archive Storage in the Cloud",
            "name": "Amazon Glacier"
        },

在他们更改该页面之前,它会起作用:)

相关问题