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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南