:type client_creator: callable :param client_creator: A callable that creates a client taking arguments like ``Session.create_client``. :type source_credentials: Credentials :param source_credentials: The credentials to use to create the clie
(
self,
client_creator,
source_credentials,
role_arn,
extra_args=None,
mfa_prompter=None,
cache=None,
expiry_window_seconds=None,
)
| 853 | |
| 854 | class AssumeRoleCredentialFetcher(BaseAssumeRoleCredentialFetcher): |
| 855 | def __init__( |
| 856 | self, |
| 857 | client_creator, |
| 858 | source_credentials, |
| 859 | role_arn, |
| 860 | extra_args=None, |
| 861 | mfa_prompter=None, |
| 862 | cache=None, |
| 863 | expiry_window_seconds=None, |
| 864 | ): |
| 865 | """ |
| 866 | :type client_creator: callable |
| 867 | :param client_creator: A callable that creates a client taking |
| 868 | arguments like ``Session.create_client``. |
| 869 | |
| 870 | :type source_credentials: Credentials |
| 871 | :param source_credentials: The credentials to use to create the |
| 872 | client for the call to AssumeRole. |
| 873 | |
| 874 | :type role_arn: str |
| 875 | :param role_arn: The ARN of the role to be assumed. |
| 876 | |
| 877 | :type extra_args: dict |
| 878 | :param extra_args: Any additional arguments to add to the assume |
| 879 | role request using the format of the botocore operation. |
| 880 | Possible keys include, but may not be limited to, |
| 881 | DurationSeconds, Policy, SerialNumber, ExternalId and |
| 882 | RoleSessionName. |
| 883 | |
| 884 | :type mfa_prompter: callable |
| 885 | :param mfa_prompter: A callable that returns input provided by the |
| 886 | user (i.e raw_input, getpass.getpass, etc.). |
| 887 | |
| 888 | :type cache: dict |
| 889 | :param cache: An object that supports ``__getitem__``, |
| 890 | ``__setitem__``, and ``__contains__``. An example of this is |
| 891 | the ``JSONFileCache`` class in aws-cli. |
| 892 | |
| 893 | :type expiry_window_seconds: int |
| 894 | :param expiry_window_seconds: The amount of time, in seconds, |
| 895 | """ |
| 896 | self._source_credentials = source_credentials |
| 897 | self._mfa_prompter = mfa_prompter |
| 898 | if self._mfa_prompter is None: |
| 899 | self._mfa_prompter = getpass.getpass |
| 900 | |
| 901 | super().__init__( |
| 902 | client_creator, |
| 903 | role_arn, |
| 904 | extra_args=extra_args, |
| 905 | cache=cache, |
| 906 | expiry_window_seconds=expiry_window_seconds, |
| 907 | ) |
| 908 | |
| 909 | def _get_credentials(self): |
| 910 | """Get credentials by calling assume role.""" |