aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.56k stars 4.13k forks source link

GetServiceQuota not providing Quota Value #8584

Closed nimble closed 6 months ago

nimble commented 7 months ago

Describe the bug

Getting a similar error to this:

An error occurred (NoSuchResourceException) when calling the GetServiceQuota operation: The request failed because applied value for the specified context Id do not exist.

I'm leveraging the boto3 python library which is giving me back the error message above. My resource doesn't have a resource quota value set however, it does have an Account Quota Value & AWS default quota value.

By definition in the AWS Console it displays the following message, "Applied quota value is the first set value in the following order: resource quota value, account quota value then AWS default quota value".

If I'm not to have a Resource quota value set, shouldn't it still be giving me the values mentioned above by definition?...

Example:

resource_quota_value

Expected Behavior

I expected to get back the account quota value atleast.

Current Behavior

Not giving me back anything despite there being an account quota value and aws default quota value applied.

Reproduction Steps

Simply run:

aws service-quotas get-service-quota --service-code 'connect' --quota-code 'L-20CD02F7' --context-id 'CONTEXT-ID-HERE' --profile testprofile --debug

Possible Solution

No response

Additional Information/Context

This is with the --debug parameter:

qx76 ~  $ aws service-quotas get-service-quota --service-code 'connect' --quota-code 'L-20CD02F7' --context-id 'REDACTED' --profile testprofile --debug
2024-03-19 00:12:15,218 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.32.65 Python/3.11.1 Darwin/23.3.0 botocore/1.34.65
2024-03-19 00:12:15,218 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['service-quotas', 'get-service-quota', '--service-code', 'connect', '--quota-code', 'L-20CD02F7', '--context-id', 'REDACTED', '--profile', 'testprofile', '--debug']
2024-03-19 00:12:15,218 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x10b750d60>
2024-03-19 00:12:15,219 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x10aeee340>
2024-03-19 00:12:15,219 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x10af33880>
2024-03-19 00:12:15,222 - MainThread - botocore.utils - DEBUG - IMDS ENDPOINT: http://169.254.169.254/
2024-03-19 00:12:15,231 - MainThread - botocore.credentials - DEBUG - Skipping environment variable credential check because profile name was explicitly set.
2024-03-19 00:12:15,231 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x10b590220>
2024-03-19 00:12:15,232 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/data/service-quotas/2019-06-24/service-2.json.gz
2024-03-19 00:12:15,234 - MainThread - botocore.hooks - DEBUG - Event building-command-table.service-quotas: calling handler <function add_waiters at 0x10b752c00>
2024-03-19 00:12:15,265 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('service-code', <awscli.arguments.CLIArgument object at 0x10c17c810>), ('quota-code', <awscli.arguments.CLIArgument object at 0x10c17ca10>), ('context-id', <awscli.arguments.CLIArgument object at 0x10c17cb90>)])
2024-03-19 00:12:15,265 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.service-quotas.get-service-quota: calling handler <function add_streaming_output_arg at 0x10b751260>
2024-03-19 00:12:15,265 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.service-quotas.get-service-quota: calling handler <function add_cli_input_json at 0x10af54220>
2024-03-19 00:12:15,266 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.service-quotas.get-service-quota: calling handler <function unify_paging_params at 0x10b6cc7c0>
2024-03-19 00:12:15,295 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/data/service-quotas/2019-06-24/paginators-1.json
2024-03-19 00:12:15,295 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.service-quotas.get-service-quota: calling handler <function add_generate_skeleton at 0x10b6a4ae0>
2024-03-19 00:12:15,295 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.service-quotas.get-service-quota: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x10c17cfd0>>
2024-03-19 00:12:15,295 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.service-quotas.get-service-quota: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x10c172010>>
2024-03-19 00:12:15,295 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.service-quotas.get-service-quota: calling handler <function update_endpoint_url at 0x10b7799e0>
2024-03-19 00:12:15,296 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.servicequotas.get-service-quota.service-code: calling handler <awscli.paramfile.URIArgumentHandler object at 0x109271fd0>
2024-03-19 00:12:15,296 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.service-quotas.get-service-quota: calling handler <awscli.argprocess.ParamShorthandParser object at 0x10af0f0d0>
2024-03-19 00:12:15,297 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'connect' for parameter "service_code": 'connect'
2024-03-19 00:12:15,297 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.servicequotas.get-service-quota.quota-code: calling handler <awscli.paramfile.URIArgumentHandler object at 0x109271fd0>
2024-03-19 00:12:15,297 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.service-quotas.get-service-quota: calling handler <awscli.argprocess.ParamShorthandParser object at 0x10af0f0d0>
2024-03-19 00:12:15,297 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'L-20CD02F7' for parameter "quota_code": 'L-20CD02F7'
2024-03-19 00:12:15,297 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.servicequotas.get-service-quota.context-id: calling handler <awscli.paramfile.URIArgumentHandler object at 0x109271fd0>
2024-03-19 00:12:15,297 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.service-quotas.get-service-quota: calling handler <awscli.argprocess.ParamShorthandParser object at 0x10af0f0d0>
2024-03-19 00:12:15,297 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'REDACTED' for parameter "context_id": 'REDACTED'
2024-03-19 00:12:15,297 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.servicequotas.get-service-quota.cli-input-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x109271fd0>
2024-03-19 00:12:15,297 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.servicequotas.get-service-quota.generate-cli-skeleton: calling handler <awscli.paramfile.URIArgumentHandler object at 0x109271fd0>
2024-03-19 00:12:15,297 - MainThread - botocore.hooks - DEBUG - Event calling-command.service-quotas.get-service-quota: calling handler <bound method CliInputJSONArgument.add_to_call_parameters of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x10c17cfd0>>
2024-03-19 00:12:15,298 - MainThread - botocore.hooks - DEBUG - Event calling-command.service-quotas.get-service-quota: calling handler <bound method GenerateCliSkeletonArgument.generate_json_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x10c172010>>
2024-03-19 00:12:15,298 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2024-03-19 00:12:15,298 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2024-03-19 00:12:15,298 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: sso
2024-03-19 00:12:15,298 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2024-03-19 00:12:15,298 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials
2024-03-19 00:12:15,300 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/data/endpoints.json
2024-03-19 00:12:15,319 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/data/sdk-default-configuration.json
2024-03-19 00:12:15,319 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x10abedb20>
2024-03-19 00:12:15,353 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/data/service-quotas/2019-06-24/endpoint-rule-set-1.json.gz
2024-03-19 00:12:15,353 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/data/partitions.json
2024-03-19 00:12:15,354 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.service-quotas: calling handler <function add_generate_presigned_url at 0x10aa262a0>
2024-03-19 00:12:15,355 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for service-quotas via: environment_service
2024-03-19 00:12:15,355 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for service-quotas via: environment_global
2024-03-19 00:12:15,355 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for service-quotas via: config_service
2024-03-19 00:12:15,355 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for service-quotas via: config_global
2024-03-19 00:12:15,355 - MainThread - botocore.configprovider - DEBUG - No configured endpoint found.
2024-03-19 00:12:15,357 - MainThread - botocore.endpoint - DEBUG - Setting servicequotas timeout as (60, 60)
2024-03-19 00:12:15,358 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/data/_retry.json
2024-03-19 00:12:15,359 - MainThread - botocore.client - DEBUG - Registering retry handlers for service: service-quotas
2024-03-19 00:12:15,360 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.service-quotas.GetServiceQuota: calling handler <function generate_idempotent_uuid at 0x10abef560>
2024-03-19 00:12:15,361 - MainThread - botocore.regions - DEBUG - Calling endpoint provider with parameters: {'Region': 'ca-central-1', 'UseDualStack': False, 'UseFIPS': False}
2024-03-19 00:12:15,362 - MainThread - botocore.regions - DEBUG - Endpoint provider result: https://servicequotas.ca-central-1.amazonaws.com
2024-03-19 00:12:15,362 - MainThread - botocore.hooks - DEBUG - Event before-call.service-quotas.GetServiceQuota: calling handler <function add_recursion_detection_header at 0x10abeea20>
2024-03-19 00:12:15,363 - MainThread - botocore.hooks - DEBUG - Event before-call.service-quotas.GetServiceQuota: calling handler <function inject_api_version_header_if_needed at 0x10ac15080>
2024-03-19 00:12:15,363 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=GetServiceQuota) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'ServiceQuotasV20190624.GetServiceQuota', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'aws-cli/1.32.65 md/Botocore#1.34.65 ua/2.0 os/macos#23.3.0 md/arch#x86_64 lang/python#3.11.1 md/pyimpl#CPython cfg/retry-mode#legacy botocore/1.34.65'}, 'body': b'{"ServiceCode": "connect", "QuotaCode": "L-20CD02F7", "ContextId": "REDACTED"}', 'url': 'https://servicequotas.ca-central-1.amazonaws.com/', 'context': {'client_region': 'ca-central-1', 'client_config': <botocore.config.Config object at 0x10c68af50>, 'has_streaming_input': False, 'auth_type': None}}
2024-03-19 00:12:15,363 - MainThread - botocore.hooks - DEBUG - Event request-created.service-quotas.GetServiceQuota: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x10c68af10>>
2024-03-19 00:12:15,363 - MainThread - botocore.hooks - DEBUG - Event choose-signer.service-quotas.GetServiceQuota: calling handler <function set_operation_specific_signer at 0x10abef420>
2024-03-19 00:12:15,364 - MainThread - botocore.auth - DEBUG - Calculating signature using v4 auth.
2024-03-19 00:12:15,364 - MainThread - botocore.auth - DEBUG - CanonicalRequest:
POST
/

content-type:application/x-amz-json-1.1
host:servicequotas.ca-central-1.amazonaws.com
x-amz-date:20240319T041215Z
x-amz-target:ServiceQuotasV20190624.GetServiceQuota

content-type;host;x-amz-date;x-amz-target
91e5af3152544cb93b0183abeeddaeb13b47dd8c7a745a5925150d9a29ec4ff1
2024-03-19 00:12:15,364 - MainThread - botocore.auth - DEBUG - StringToSign:
AWS4-HMAC-SHA256
20240319T041215Z
20240319/ca-central-1/servicequotas/aws4_request
66f535621ac6385f6cb5aaef54f9a1a5799030a480e0087dc6ad3832ce38527d
2024-03-19 00:12:15,364 - MainThread - botocore.auth - DEBUG - Signature:
87bb17e9bfa5987915d03d5dad32c5d38a7930d951efa721dc581f5736e6a8a8
2024-03-19 00:12:15,364 - MainThread - botocore.hooks - DEBUG - Event request-created.service-quotas.GetServiceQuota: calling handler <function add_retry_headers at 0x10ac15800>
2024-03-19 00:12:15,364 - MainThread - botocore.endpoint - DEBUG - Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://servicequotas.ca-central-1.amazonaws.com/, headers={'X-Amz-Target': b'ServiceQuotasV20190624.GetServiceQuota', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'aws-cli/1.32.65 md/Botocore#1.34.65 ua/2.0 os/macos#23.3.0 md/arch#x86_64 lang/python#3.11.1 md/pyimpl#CPython cfg/retry-mode#legacy botocore/1.34.65', 'X-Amz-Date': b'20240319T041215Z', 'Authorization': b'AWS4-HMAC-SHA256 Credential=AKIAQVLLUODULXSR37Y5/20240319/ca-central-1/servicequotas/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=87bb17e9bfa5987915d03d5dad32c5d38a7930d951efa721dc581f5736e6a8a8', 'amz-sdk-invocation-id': b'fda577d5-3c72-4683-ae3a-e5cd19318a76', 'amz-sdk-request': b'attempt=1', 'Content-Length': '157'}>
2024-03-19 00:12:15,366 - MainThread - botocore.httpsession - DEBUG - Certificate path: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/certifi/cacert.pem
2024-03-19 00:12:15,367 - MainThread - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): servicequotas.ca-central-1.amazonaws.com:443
2024-03-19 00:12:15,936 - MainThread - urllib3.connectionpool - DEBUG - https://servicequotas.ca-central-1.amazonaws.com:443 "POST / HTTP/1.1" 400 132
2024-03-19 00:12:15,936 - MainThread - botocore.parsers - DEBUG - Response headers: {'Date': 'Tue, 19 Mar 2024 04:12:16 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '132', 'Connection': 'keep-alive', 'x-amzn-RequestId': 'a2e61bae-1670-4483-9f75-b514be2ade74'}
2024-03-19 00:12:15,936 - MainThread - botocore.parsers - DEBUG - Response body:
b'{"__type":"NoSuchResourceException","Message":"The request failed because applied value for the specified context Id do not exist."}'
2024-03-19 00:12:15,937 - MainThread - botocore.parsers - DEBUG - Response headers: {'Date': 'Tue, 19 Mar 2024 04:12:16 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '132', 'Connection': 'keep-alive', 'x-amzn-RequestId': 'a2e61bae-1670-4483-9f75-b514be2ade74'}
2024-03-19 00:12:15,937 - MainThread - botocore.parsers - DEBUG - Response body:
b'{"__type":"NoSuchResourceException","Message":"The request failed because applied value for the specified context Id do not exist."}'
2024-03-19 00:12:15,937 - MainThread - botocore.hooks - DEBUG - Event needs-retry.service-quotas.GetServiceQuota: calling handler <botocore.retryhandler.RetryHandler object at 0x10c693910>
2024-03-19 00:12:15,937 - MainThread - botocore.retryhandler - DEBUG - No retry needed.
2024-03-19 00:12:15,938 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/awscli/clidriver.py", line 217, in main
    return command_table[parsed_args.command](remaining, parsed_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/awscli/clidriver.py", line 361, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/awscli/clidriver.py", line 530, in __call__
    return self._operation_caller.invoke(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/awscli/clidriver.py", line 652, in invoke
    response = self._make_client_call(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/awscli/clidriver.py", line 664, in _make_client_call
    response = getattr(client, xform_name(operation_name))(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/client.py", line 553, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/botocore/client.py", line 1009, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.NoSuchResourceException: An error occurred (NoSuchResourceException) when calling the GetServiceQuota operation: The request failed because applied value for the specified context Id do not exist.
2024-03-19 00:12:15,941 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

An error occurred (NoSuchResourceException) when calling the GetServiceQuota operation: The request failed because applied value for the specified context Id do not exist.

CLI version used

aws-cli/1.32.65 Python/3.11.1 Darwin/23.3.0 botocore/1.34.65

Environment details (OS name and version, etc.)

MacOS 14.3.1 (23D60)

tim-finnigan commented 6 months ago

Hi @nimble thanks for reaching out and for your patience here. The GetServiceQuota API is used in both the get-service-quota (CLI) and get_service_quota (Boto3) commands. So if there's an API issue here then we may need to escalate this to the Service Quotas team.

However, upon testing this command aws service-quotas get-service-quota --service-code 'connect' --quota-code 'L-20CD02F7', I do receive the following response:

{
    "Quota": {
        "ServiceCode": "connect",
        "ServiceName": "Amazon Connect",
        "QuotaArn": "arn:aws:servicequotas:us-west-2:<account-id>:connect/L-20CD02F7",
        "QuotaCode": "L-20CD02F7",
        "QuotaName": "Hours of operation per instance",
        "Value": 100.0,
        "Unit": "None",
        "Adjustable": true,
        "GlobalQuota": false,
        "QuotaAppliedAtLevel": "ACCOUNT",
        "QuotaContext": {
            "ContextScope": "RESOURCE",
            "ContextScopeType": "AWS::Connect::Instance",
            "ContextId": "*"
        }
    }
}

So I think the issue here may be specifically with the --context-id parameter used. When I passed my account ID as this parameter then the command also ran successfully.

I also noticed that you are using an older version of the CLI. We recommend using a more recent version in order to have access to the latest updates (which sometimes also helps resolve issues like these.) We recommend migrating to v2 of the CLI if you can, otherwise here is the v1 CHANGELOG where you can reference the latest versions in v1.

nimble commented 6 months ago

Hey @tim-finnigan,

Thanks for replying (I did end up updating my CLI; this cleared some few issues I was having). But anyways, I've proposed the following to Amazon:

I propose an enhancement to the Service Quotas API where, instead of immediately returning an error when a resource-specific quota isn't found, it could automatically fallback to return the next available quota value in the hierarchy (i.e., resource quota value, account quota value, and then AWS default quota value).

Thanks.

tim-finnigan commented 6 months ago

Thanks for following up and sharing your proposal. Changes to service API behavior are generally rare because of the need to retain backwards compatibility with existing scripts. That being said, maybe there's an opportunity to improve the documentation here regarding the curent behavior. In which case I'd recommend using the Provide feedback at the bottom of the API documentation page, and any documentation updates would automatically get reflected in the CLI docs. Otherwise if you'd like to expand on your proposed feature request further you can reach out through AWS Support or create an issue in our cross-SDK repository.

github-actions[bot] commented 6 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.