I am not able to fetch service quota for s3 at account level.

0

I can fetch default using get_aws_default_service_quota() but not get_service_quota() Ultimate goal is to create an alarm for the servicequota utilization.

  • Can you give us more details, what is the error you are getting, why does the call not work for you? Paste some sample code and error outputs?

  • Here is the code I am executing: s3_client = boto3.client('s3', aws_access_key_id=keyId, aws_secret_access_key=accessKey)

    client = boto3.client('service-quotas', aws_access_key_id=“keyId”, aws_secret_access_key=“accessKey” ) s3_quota_resp = client.get_aws_default_service_quota( ServiceCode='s3', QuotaCode='L-DC2B2D3D' ) print(s3_quota_resp)

    ----In the response we can only see default value. not the updated one ---- Response: 'QuotaName': 'General purpose buckets', 'Value': 100.0, 'Unit': 'None', 'Adjustable': True, 'GlobalQuota': False},

    ---- and if I run get_service_quota() . then ---- Response: aise error_class(parsed_response, operation_name) botocore.errorfactory.NoSuchResourceException: An error occurred (NoSuchResourceException) when calling the GetServiceQuota operation: The request failed because the specified quota and service do not exist.

Pratik
asked 4 months ago285 views
2 Answers
0

Hello,

I understand that you are attempting to fetch service quotas for Amazon S3 service for your account by using the GetServiceQuota API.

The Service Quota APIs are not fully onboarded for S3 as of now and I can confirm that the GetServiceQuota API call does not return the applied values for S3 at the moment. The GetAWSDefaultServiceQuota API/CLI command would work as it is functional for all services. However this API would not give you the applied quota values for S3.

Fully onboarding these APIs for S3 is a part of future roadmap. I encourage you to keep an eye on our What's New page and our Announcements blog, as these are common channels used by AWS to publish the new feature launches:

[+] What's New in AWS - https://aws.amazon.com/new/ [+] AWS Blog - https://aws.amazon.com/blogs/aws/tag/announcements/

profile pictureAWS
SUPPORT ENGINEER
answered 4 months ago
0

According to BOTO3 documentation you should be using get_service_quota to return a quota for a service where you are using get_aws_default_service_quota

This should work in theory. get_service_quota(ServiceCode='s3',QuotaCode=''L-DC2B2D3D')

I have just tested this and I return a result with no quotas for S3 as by default there isnt any for my account. Give this a go. If it works, then you may need to pass each quota through a loop with get_service_quota

Update AWSservicecode='ses' to AWSservicecode='s3'

import boto3

from botocore.config import Config
from aws_regions import available_regions

AWSservicecode='ses'

def get_service_quota():
    regions = available_regions("ec2")
    for region in regions:
        my_config = Config(region_name=region)
        quotas = boto3.client("service-quotas", config=my_config)
        response = quotas.list_service_quotas(ServiceCode=AWSservicecode)
        for ServiceCode in response['Quotas']:
            for attribute, value in ServiceCode.items():
                if attribute=='QuotaCode':
                    response = quotas.get_service_quota(ServiceCode=AWSservicecode,QuotaCode=value)
                    print(region,AWSservicecode,response['Quota']['QuotaName'],response['Quota']['Value'])
profile picture
EXPERT
answered 4 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