如何通过boto3获取AWS的配额?

时间:2019-08-14 11:31:29

标签: python python-3.x amazon-web-services boto3

我正在研究boto3-适用于AWS的SDK python。

我从ec2的简单服务配额开始,但总是以以下错误结束,

import boto3

quota_client = boto3.client('service-quotas')
response = quota_client.get_service_quota(
ServiceCode='ec2'
)

错误:

botocore.exceptions.UnknownServiceError: Unknown service: 'service- 
quotas'. Valid service names are: acm, acm-pca, alexaforbusiness, 
amplify, apigateway, apigatewaymanagementapi, apigatewayv2, 
application-autoscaling, appmesh, appstream, appsync, athena, 
autoscaling, autoscaling-plans, backup, batch, budgets, ce, chime, 
cloud9, clouddirectory, cloudformation, cloudfront, cloudhsm, 
cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, 
codebuild, codecommit, codedeploy, codepipeline, codestar, cognito- 
identity, cognito-idp, cognito-sync, comprehend, comprehendmedical, 
config, connect, cur, datapipeline, datasync, dax, devicefarm, 
directconnect, discovery, dlm, dms, docdb, ds, dynamodb, 
dynamodbstreams, ec2, ecr, ecs, efs, eks, elasticache, 
elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, 
firehose, fms, fsx, gamelift, glacier, globalaccelerator, glue, 
greengrass, groundstation, guardduty, health, iam, importexport, 
inspector, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click- 
projects, iotanalytics, iotevents, iotevents-data, iotthingsgraph, 
kafka, kinesis, kinesis-video-archived-media, kinesis-video-media, 
 kinesisanalytics, kinesisanalyticsv2, kinesisvideo, kms, lambda, lex- 
models, lex-runtime, license-manager, lightsail, logs, 
 machinelearning, macie, managedblockchain, marketplace-entitlement, 
 marketplacecommerceanalytics, mediaconnect, mediaconvert, medialive, 
 mediapackage, mediapackage-vod, mediastore, mediastore-data, 
mediatailor, meteringmarketplace, mgh, mobile, mq, mturk, neptune, 
 opsworks, opsworkscm, organizations, personalize, personalize-events, 
 personalize-runtime, pi, pinpoint, pinpoint-email, pinpoint-sms-voice, polly, pricing, 
 quicksight, ram, rds, rds-data, redshift, rekognition, resource-groups, 
 resourcegroupstaggingapi, robomaker, route53, route53domains, 
 route53resolver, s3, s3control, sagemaker, sagemaker-runtime, sdb, 
secretsmanager, securityhub, serverlessrepo, servicecatalog, 
servicediscovery, ses, shield, signer, sms, sms-voice, snowball, sns, sqs, 
ssm, stepfunctions, storagegateway, sts, support, swf, textract, 
transcribe, transfer, translate, waf, waf-regional, workdocs, worklink, 
workmail, workspaces, xray

文档页面显示了boto3支持的服务配额,但看起来好像不行,还是我在这里做错了什么?

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/service-quotas.html

1 个答案:

答案 0 :(得分:0)

我可以重现当前的boto3-1.9.174 botocore-1.12.174安装问题。

然后我做了:

pip install boto3 --upgrade

它使我迁移到boto3-1.9.208 botocore-1.12.208版,并且运行正常。

我尝试使用Python虚拟环境隔离库以方便更新。