Python botocore.session.get_credentials() Examples
The following are 5
code examples of botocore.session.get_credentials().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
botocore.session
, or try the search function
.
Example #1
Source File: s3.py From idseq-dag with MIT License | 6 votes |
def _get_credentials(): log.write("Refreshing credentials.") session = botocore.session.Session() credentials = session.get_credentials() return { "AWS_ACCESS_KEY_ID": credentials.access_key, "AWS_SECRET_ACCESS_KEY": credentials.secret_key, "AWS_SESSION_TOKEN": credentials.token, "AWS_DEFAULT_REGION": session.create_client("s3").meta.region_name }
Example #2
Source File: aws_api.py From gimel with MIT License | 5 votes |
def check_aws_credentials(): session = botocore.session.get_session() session.get_credentials().access_key session.get_credentials().secret_key
Example #3
Source File: aws_api.py From cronyo with MIT License | 5 votes |
def check_aws_credentials(): session = botocore.session.get_session() session.get_credentials().access_key session.get_credentials().secret_key
Example #4
Source File: get_token.py From bash-lambda-layer with MIT License | 5 votes |
def _get_presigned_url(self, cluster_name, role_arn): session = self._session_handler.get_session( self._region_name, role_arn ) if self._region_name is None: self._region_name = session.get_config_variable('region') loader = botocore.loaders.create_loader() data = loader.load_data("endpoints") endpoint_resolver = botocore.regions.EndpointResolver(data) endpoint = endpoint_resolver.construct_endpoint( AUTH_SERVICE, self._region_name ) signer = RequestSigner( ServiceId(AUTH_SERVICE), self._region_name, AUTH_SERVICE, AUTH_SIGNING_VERSION, session.get_credentials(), session.get_component('event_emitter') ) action_params='Action=' + AUTH_COMMAND + '&Version=' + AUTH_API_VERSION params = { 'method': 'GET', 'url': 'https://' + endpoint["hostname"] + '/?' + action_params, 'body': {}, 'headers': {CLUSTER_NAME_HEADER: cluster_name}, 'context': {} } url=signer.generate_presigned_url( params, region_name=endpoint["credentialScope"]["region"], operation_name='', expires_in=URL_TIMEOUT ) return url
Example #5
Source File: awscurl.py From awscurl with MIT License | 4 votes |
def load_aws_config(access_key, secret_key, security_token, credentials_path, profile): # type: (str, str, str, str, str) -> Tuple[str, str, str] """ Load aws credential configuration, by parsing credential file, then try to fall back to botocore, by checking (access_key,secret_key) are not (None,None) """ if access_key is None or secret_key is None: try: exists = os.path.exists(credentials_path) __log('Credentials file \'{0}\' exists \'{1}\''.format(credentials_path, exists)) config = configparser.ConfigParser() config.read(credentials_path) while True: if access_key is None and config.has_option(profile, "aws_access_key_id"): access_key = config.get(profile, "aws_access_key_id") else: break if secret_key is None and config.has_option(profile, "aws_secret_access_key"): secret_key = config.get(profile, "aws_secret_access_key") else: break if security_token is None and config.has_option(profile, "aws_session_token"): security_token = config.get(profile, "aws_session_token") break except configparser.NoSectionError as exception: __log('AWS profile \'{0}\' not found'.format(exception.args)) raise exception except configparser.NoOptionError as exception: __log('AWS profile \'{0}\' is missing \'{1}\''.format(profile, exception.args)) raise exception except ValueError as exception: __log(exception) raise exception # try to load instance credentials using botocore if access_key is None or secret_key is None: try: __log("loading botocore package") import botocore except ImportError: __log("botocore package could not be loaded") botocore = None if botocore: import botocore.session session = botocore.session.get_session() cred = session.get_credentials() access_key, secret_key, security_token = cred.access_key, cred.secret_key, cred.token return access_key, secret_key, security_token