简体   繁体   English

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

[英]How to get quotas of AWS via boto3?

I'm working on boto3 - SDK python for AWS.我正在研究 boto3 - 适用于 AWS 的 SDK python。

I am starting with simple service quota for ec2 but always ending up with the below error,我从 ec2 的简单服务配额开始,但总是以以下错误结束,

import boto3

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

Error:错误:

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

The documentation page shows that service-quotas supported in boto3 but looks like it's not or am I doing anything incorrect here?文档页面显示 boto3 支持服务配额,但看起来不是,或者我在这里做错了什么?

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

I could reproduce the problem with my current boto3-1.9.174 botocore-1.12.174 installation.我可以用我当前的boto3-1.9.174 botocore-1.12.174安装重现这个问题。

I then did:然后我做了:

pip install boto3 --upgrade

It moved me to version boto3-1.9.208 botocore-1.12.208 and it works fine.它将我移至boto3-1.9.208 botocore-1.12.208版本,并且工作正常。

I try to use Python virtual environments to isolate libraries for easy updating.我尝试使用 Python 虚拟环境来隔离库以便于更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM