aiobotocore: get_credentials() fails on AioSession

Using aiobotocore 0.6.0, python 3.6.3

Executing:

aiobotocore.get_session().get_credentials().secret_key

Fails with the following error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/venv/lib/python3.6/site-packages/botocore/credentials.py", line 336, in secret_key
    self._refresh()
  File "/venv/lib/python3.6/site-packages/botocore/credentials.py", line 415, in _refresh
    self._protected_refresh(is_mandatory=is_mandatory_refresh)
  File "/venv/lib/python3.6/site-packages/botocore/credentials.py", line 431, in _protected_refresh
    metadata = self._refresh_using()
  File "/venv/lib/python3.6/site-packages/botocore/credentials.py", line 555, in fetch_credentials
    return self._get_cached_credentials()
  File "/venv/lib/python3.6/site-packages/botocore/credentials.py", line 566, in _get_cached_credentials
    self._write_to_cache(response)
  File "/venv/lib/python3.6/site-packages/botocore/credentials.py", line 591, in _write_to_cache
    self._cache[self._cache_key] = deepcopy(response)
  File "/usr/lib/python3.6/copy.py", line 169, in deepcopy
    rv = reductor(4)
TypeError: can't pickle generator objects

When hitting the AssumeRoleProvider. It appears that the provider tries to write the client to cache but fails to serialize the Aio client.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (1 by maintainers)

Most upvoted comments

temp monkeypatch fix:

orig_create_client = botocore.credentials.AssumeRoleCredentialFetcher._create_client


def _create_client(self):
    frozen_credentials = self._source_credentials.get_frozen_credentials()
    if not getattr(self, '_boto_session', None):
        self._boto_session = botocore.session.Session()

    return self._boto_session.create_client(
        'sts',
        aws_access_key_id=frozen_credentials.access_key,
        aws_secret_access_key=frozen_credentials.secret_key,
        aws_session_token=frozen_credentials.token,
    )

botocore.credentials.AssumeRoleCredentialFetcher._create_client = _create_client