python v2.7.11
boto3 v1.4.2
I'm trying to access an SQS resource using boto3 with the credentials set as environment variables. My AWS auto generated credentials have special chars in them. Thus I have something like this in my ENV:
AWS_ACCESS_KEY_ID=abc123
AWS_SECRET_ACCESS_KEY=abc/123+4
When I call boto3.resource('sqs') it fails with the following error and stack trace:
File "/usr/local/lib/python2.7/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 251, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 526, in _make_api_call
operation_model, request_dict)
File "/usr/local/lib/python2.7/site-packages/botocore/endpoint.py", line 141, in make_request
return self._send_request(request_dict, operation_model)
File "/usr/local/lib/python2.7/site-packages/botocore/endpoint.py", line 170, in _send_request
success_response, exception):
File "/usr/local/lib/python2.7/site-packages/botocore/endpoint.py", line 249, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/usr/local/lib/python2.7/site-packages/botocore/hooks.py", line 227, in emit
return self._emit(event_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/hooks.py", line 210, in _emit
response = handler(**kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 269, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
ValueError: Invalid header value 'AWS4-HMAC-SHA256 Credential=REDACTED\n/20161206/us-east-1/sqs/aws4_request, SignedHeaders=host;x-amz-date, Signature=6d7aa3REDACTED'
This also fails if I pass them into the client() method. However it does work perfectly if I inject them into the ~/.aws/credentials file.
I just discovered the tool I was using to manage credentials was appending a newline to the end of the env vars, which would explain the behaviour. Closing the issue.
Most helpful comment
I just discovered the tool I was using to manage credentials was appending a newline to the end of the env vars, which would explain the behaviour. Closing the issue.