How to get the existing VPC Quota for an AWS Account using boto3?

0

I am trying to get the current value of the VPC Quota of an AWS Account using boto3. This is how I am generating a request

response = client.describe_account_attributes( )
print(response)

In the response, I'm getting the EC2 Instance Quota and EIP Quota as well. Likewise, I am trying to find a way of using boto3 to get the VPC Quota for an AWS Account without passing any parameter like 'ServiceCode', etc

{
    'AccountAttributes': [
        {
            'AttributeName': 'supported-platforms',
            'AttributeValues': [
                {
                    'AttributeValue': 'EC2',
                },
                {
                    'AttributeValue': 'VPC',
                },
            ],
        },
        {
            'AttributeName': 'vpc-max-security-groups-per-interface',
            'AttributeValues': [
                {
                    'AttributeValue': '5',
                },
            ],
        },
        {
            'AttributeName': 'max-elastic-ips',
            'AttributeValues': [
                {
                    'AttributeValue': '5',
                },
            ],
        },
        {
            'AttributeName': 'max-instances',
            'AttributeValues': [
                {
                    'AttributeValue': '20',
                },
            ],
        },
        {
            'AttributeName': 'vpc-max-elastic-ips',
            'AttributeValues': [
                {
                    'AttributeValue': '5',
                },
            ],
        },
        {
            'AttributeName': 'default-vpc',
            'AttributeValues': [
                {
                    'AttributeValue': 'none',
                },
            ],
        },
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}

I have tried almost all possible ways mentioned in the AWS Boto3 Documentation, but still no luck. I welcome any suggestions/advice. Thanks in advance !!

profile picture
質問済み 1年前334ビュー
2回答
0

Why don't you want to use "ServiceCode"?
I think we can use "ServiceCode" and check the quota in "list_service_quotas".
Is there any reason why this is not possible?
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/service-quotas/client/list_service_quotas.html#

profile picture
エキスパート
回答済み 1年前
0

From the question, it's little unclear why there is a requirement to avoid passing service code, when we need to get service quotas for a specific service as that's a required parameter. describe_account_attributes is an ec2 api which doesn't require any additional parameters so both are completely different and these two shouldn't be compared as servicequotas is generic while latter one is specific to ec2.

CLI:

aws service-quotas list-service-quotas --service-code vpc --query 'Quotas[*].[QuotaName,Value]' --profile <profile>

Boto3:

sq_client = boto3.client('service-quotas')

sq_client = list_service_quotas(ServiceCode='vpc')

Service Quotas API is designed to keep every service in it and to get the result specific to one service, we have to have that service code specified.

profile pictureAWS
エキスパート
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ