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
질문됨 일 년 전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
전문가
답변함 일 년 전
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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠