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
asked 10 months ago325 views
2 Answers
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
EXPERT
answered 10 months ago
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
EXPERT
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions