Open msaltz-boticario opened 2 years ago
Hi @msaltz-boticario thanks for reaching out. I tried to reproduce the issue but was able to filter by prefix-list-name
. I would double-check that the value you used doesn't contain any typos. Also if you share your debug logs by adding boto3.set_stream_logger('')
to your code that could give us more insight into what's going on, but it looks like a 200 status code was returned so I don't think there was any error.
Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.
Unfortunately, this issue still persists. I've encountered it using boto3 1.21.13. What is really interesting using aws cli in version aws-cli/2.4.24 works perfectly fine and all results are there.
@Martus0 I agree the issue is still there.
Please share your debug logs by adding boto3.set_stream_logger('')
to your code.
Here is the problem i found: if you create a prefix list as: test1(with a space in front) vs test1
If you get that prefix list by ID, The API will return the name without a space in front due to stripping. However, you cannot filter by name without space in front.
It should not allow you to create a prefix list with a space in the front if the API does not return the space.
I created a prefix list called: test500(space in front)
However API returns as: 'PrefixListName': 'test500' (no space)
However if you filter on test500 without a space it will not come up as a result
Here is the response: 2022-03-16 10:51:46,521 botocore.loaders [DEBUG] Loading JSON file: C:\Users\msaltz\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\data\ec2\2016-11-15\paginators-1.json 2022-03-16 10:51:46,523 botocore.hooks [DEBUG] Event before-parameter-build.ec2.DescribeManagedPrefixLists: calling handler <bound method ParameterAlias.alias_parameter_in_call of <botocore.handlers.ParameterAlias object at 0x00000274AB895EE0>> 2022-03-16 10:51:46,523 botocore.hooks [DEBUG] Event before-parameter-build.ec2.DescribeManagedPrefixLists: calling handler <function generate_idempotent_uuid at 0x00000274AB899A60> 2022-03-16 10:51:46,524 botocore.hooks [DEBUG] Event before-call.ec2.DescribeManagedPrefixLists: calling handler <function add_recursion_detection_header at 0x00000274AB899700> 2022-03-16 10:51:46,524 botocore.hooks [DEBUG] Event before-call.ec2.DescribeManagedPrefixLists: calling handler <function inject_api_version_header_if_needed at 0x00000274AB8A0310> 2022-03-16 10:51:46,525 botocore.endpoint [DEBUG] Making request for OperationModel(name=DescribeManagedPrefixLists) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': 'Boto3/1.21.20 Python/3.9.1 Windows/10 Botocore/1.24.20'}, 'body': {'Action': 'DescribeManagedPrefixLists', 'Version': '2016-11-15', 'PrefixListId.1': 'pl-0655fea44f36b1f8f'}, 'url': 'https://ec2.us-east-1.amazonaws.com/', 'context': {'client_region': 'us-east-1', 'client_config': <botocore.config.Config object at 0x00000274AC24A760>, 'has_streaming_input': False, 'auth_type': None}} 2022-03-16 10:51:46,525 botocore.hooks [DEBUG] Event request-created.ec2.DescribeManagedPrefixLists: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x00000274AC24A670>> 2022-03-16 10:51:46,525 botocore.hooks [DEBUG] Event choose-signer.ec2.DescribeManagedPrefixLists: calling handler <function set_operation_specific_signer at 0x00000274AB899940> 2022-03-16 10:51:46,526 botocore.auth [DEBUG] Calculating signature using v4 auth. 2022-03-16 10:51:46,526 botocore.auth [DEBUG] CanonicalRequest: POST /
content-type:application/x-www-form-urlencoded; charset=utf-8 host:ec2.us-east-1.amazonaws.com x-amz-date:20220316T145146Z x-amz-security-token:IQoJb3JpZ2luX2VjEBcaCXVzLWVhc3QtMSJGMEQCIAlyJ+vK25FiIkD3fSScJRE0imMSBfB6fXYdMuBkSGRTAiAkFmWzZrwi/cvQP3U8s18d5uB+KimG3bqIoDOmzVJmSSqmAgiQ//////////8BEAIaDDg5ODgyMTQxMTcyOSIMOlzR1Si4mmo2O9EqKvoBHaY25INW8IKK7KcugwyOsq5SlpbRR3x+XmCOssErD3sa13opqTjnc0U4aLcZlokrTzNbTWFFMFhLAORJ4yviODlSROIgsJvYkPlblAvl9uwXgOx5ri+B3rOlW0Ty6nl+R+nzDKMN6JvkpTQiByNSfS2MwhyKBzBs+H7+Br7xxcXXf2w4j9yakmHt8F0PIxdfUOrSFAMQEteZK8RJYfd0L61ocFGa24TM2YrA2Z8sbIzfjHyGOv04d5zSnY0ASkTwlu4FHq6fulIXX6fQcb8OB7tHdWmCoHS/zscwqCR1uThfuWP3z7uIrBY1fc3cIC6hT8Reb/LpYPMBzzCz8seRBjqeAfPTPeiD6/RigzIzHh+L7jzzB4FjLHR99pMioUoO4KtJ4IxxPOpgEFUw7dMGIm84clWgxFh0jTpecpKOdMaGkvmIZ2/2umH8WVPWGsITWA1gHwaYWsk6yMTyyKMQ+WsHlWmrhHNaEE6nP+OXve0hgwcS1d+zSIzcBRxLRYfNMTVGkWgzqnN6Yc9dUSb9R0rsPZE+ydY6Ef43B8qgEouL
content-type;host;x-amz-date;x-amz-security-token
dca42e668d94e6041565b3530dc7c1227d4890276a92b168529294d2d91f270f
2022-03-16 10:51:46,527 botocore.auth [DEBUG] StringToSign:
AWS4-HMAC-SHA256
20220316T145146Z
20220316/us-east-1/ec2/aws4_request
e7f59161ae158b500e6102e54dc8a3f07b2c8721f6808a1e53740d40ee92d02c
2022-03-16 10:51:46,527 botocore.auth [DEBUG] Signature:
b355820a96da7ad21bf03e85da18c3fa09711409a3413365d09ee7b5d38245fc
2022-03-16 10:51:46,527 botocore.hooks [DEBUG] Event request-created.ec2.DescribeManagedPrefixLists: calling handler <function add_retry_headers at 0x00000274AB8A09D0>
2022-03-16 10:51:46,528 botocore.endpoint [DEBUG] Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://ec2.us-east-1.amazonaws.com/, headers={'Content-Type': b'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': b'Boto3/1.21.20 Python/3.9.1 Windows/10 Botocore/1.24.20', 'X-Amz-Date': b'20220316T145146Z', 'X-Amz-Security-Token': b'IQoJb3JpZ2luX2VjEBcaCXVzLWVhc3QtMSJGMEQCIAlyJ+vK25FiIkD3fSScJRE0imMSBfB6fXYdMuBkSGRTAiAkFmWzZrwi/cvQP3U8s18d5uB+KimG3bqIoDOmzVJmSSqmAgiQ//////////8BEAIaDDg5ODgyMTQxMTcyOSIMOlzR1Si4mmo2O9EqKvoBHaY25INW8IKK7KcugwyOsq5SlpbRR3x+XmCOssErD3sa13opqTjnc0U4aLcZlokrTzNbTWFFMFhLAORJ4yviODlSROIgsJvYkPlblAvl9uwXgOx5ri+B3rOlW0Ty6nl+R+nzDKMN6JvkpTQiByNSfS2MwhyKBzBs+H7+Br7xxcXXf2w4j9yakmHt8F0PIxdfUOrSFAMQEteZK8RJYfd0L61ocFGa24TM2YrA2Z8sbIzfjHyGOv04d5zSnY0ASkTwlu4FHq6fulIXX6fQcb8OB7tHdWmCoHS/zscwqCR1uThfuWP3z7uIrBY1fc3cIC6hT8Reb/LpYPMBzzCz8seRBjqeAfPTPeiD6/RigzIzHh+L7jzzB4FjLHR99pMioUoO4KtJ4IxxPOpgEFUw7dMGIm84clWgxFh0jTpecpKOdMaGkvmIZ2/2umH8WVPWGsITWA1gHwaYWsk6yMTyyKMQ+WsHlWmrhHNaEE6nP+OXve0hgwcS1d+zSIzcBRxLRYfNMTVGkWgzqnN6Yc9dUSb9R0rsPZE+ydY6Ef43B8qgEouL', 'Authorization': b'AWS4-HMAC-SHA256 Credential=ASIA5CRPOKOITEO3YZMS/20220316/us-east-1/ec2/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-security-token, Signature=b355820a96da7ad21bf03e85da18c3fa09711409a3413365d09ee7b5d38245fc', 'amz-sdk-invocation-id': b'eeb4314c-673c-4748-82d1-ac8461db81ff', 'amz-sdk-request': b'attempt=1', 'Content-Length': '88'}>
2022-03-16 10:51:46,530 botocore.httpsession [DEBUG] Certificate path: C:\Users\msaltz\AppData\Local\Programs\Python\Python39\lib\site-packages\certifi\cacert.pem
2022-03-16 10:51:46,530 urllib3.connectionpool [DEBUG] Starting new HTTPS connection (1): ec2.us-east-1.amazonaws.com:443
2022-03-16 10:51:46,828 urllib3.connectionpool [DEBUG] https://ec2.us-east-1.amazonaws.com:443 "POST / HTTP/1.1" 200 None
2022-03-16 10:51:46,829 botocore.parsers [DEBUG] Response headers: {'x-amzn-RequestId': '641b6a6c-aabc-40f0-8c2b-0be925833900', 'Cache-Control': 'no-cache, no-store', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'vary': 'accept-encoding', 'Content-Type': 'text/xml;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Date': 'Wed, 16 Mar 2022 14:51:46 GMT', 'Server': 'AmazonEC2'}
2022-03-16 10:51:46,834 botocore.parsers [DEBUG] Response body:
b'<?xml version="1.0" encoding="UTF-8"?>\n
Thanks @msaltz-boticario I could reproduce that behavior. In general I would recommend against using leading spaces when naming resources. But it is still worth reviewing why that space isn’t shown in the response.
We should also look at the parser for the CLI as well, as this command only worked when using both outer single and inner double quotes:
aws ec2 describe-managed-prefix-lists --filters 'Name=prefix-list-name,Values=" test1"'
(Somewhat similar to this older issue: https://github.com/aws/aws-cli/issues/1471.)
Yes, I often use scripts which copy prefix lists entry from one region to another by using the prefix list name to make sure there is no differences between regions. In scripts like this, the API becomes impossible to use. If it allows you to submit a prefix list with a leading space it should show it in the response or not allow it at all
When using a filter with prefix lists I can filter with prefix-list-id but not with prefix-list-name. If I do a describe with filter on prefix-list-id, then copy and paste the prefix list name from this describe and filter by name there is no result. I also tried copying from console same result.
Prefix list filter by ID:
response6 = ec2_newregion.describe_managed_prefix_lists( Filters=[ { 'Name': 'prefix-list-id', 'Values': ["pl-xxxx"] }] ) print(response6) {'PrefixLists': [{'PrefixListId': 'pl-xxx', 'AddressFamily': 'IPv4', 'State': 'create-complete', 'PrefixListArn': 'arn:aws:ec2:us-east-1:xxxxx', 'PrefixListName': 'pl-xxxxx', 'MaxEntries': 3, 'Version': 1, 'Tags': [{'Key': 'xxxx, 'Value': 'xxxx'}], 'OwnerId': 'xxx'}], 'ResponseMetadata': {'RequestId': 'xxxx', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'xxxxx', 'cache-control': 'no-cache, no-store', 'strict-transport-security': 'max-age=xxxx; includeSubDomains', 'vary': 'accept-encoding', 'content-type': 'text/xml;charset=UTF-8', 'transfer-encoding': 'chunked', 'date': 'Thu, 17 Feb 2022 14:38:03 GMT', 'server': 'AmazonEC2'}, 'RetryAttempts': 0}}
By Name: response6 = ec2_newregion.describe_managed_prefix_lists( Filters=[ { 'Name': 'prefix-list-name', 'Values': ["pl-xxxxx"] }] ) print(response6) Prefix list filter by name: {'PrefixLists': [], 'ResponseMetadata': {'RequestId': 'xxxxx', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'xxxxx', 'cache-control': 'no-cache, no-store', 'strict-transport-security': 'max-age=31536000; includeSubDomains', 'vary': 'accept-encoding', 'content-type': 'text/xml;charset=UTF-8', 'transfer-encoding': 'chunked', 'date': 'Thu, 17 Feb 2022 14:51:40 GMT', 'server': 'AmazonEC2'}, 'RetryAttempts':