Python botocore.credentials.JSONFileCache() Examples
The following are 4
code examples of botocore.credentials.JSONFileCache().
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.credentials
, or try the search function
.
Example #1
Source File: assumerole.py From bash-lambda-layer with MIT License | 6 votes |
def inject_assume_role_provider_cache(session, **kwargs): try: cred_chain = session.get_component('credential_provider') except ProfileNotFound: # If a user has provided a profile that does not exist, # trying to retrieve components/config on the session # will raise ProfileNotFound. Sometimes this is invalid: # # "ec2 describe-instances --profile unknown" # # and sometimes this is perfectly valid: # # "configure set region us-west-2 --profile brand-new-profile" # # Because we can't know (and don't want to know) whether # the customer is trying to do something valid, we just # immediately return. If it's invalid something else # up the stack will raise ProfileNotFound, otherwise # the configure (and other) commands will work as expected. LOG.debug("ProfileNotFound caught when trying to inject " "assume-role cred provider cache. Not configuring " "JSONFileCache for assume-role.") return provider = cred_chain.get_provider('assume-role') provider.cache = JSONFileCache(CACHE_DIR)
Example #2
Source File: aws.py From formica with MIT License | 6 votes |
def initialize(region="", profile=""): from botocore import credentials import botocore.session import os cli_cache = os.path.join(os.path.expanduser("~"), ".aws/cli/cache") params = {} if profile: params["profile"] = profile session = botocore.session.Session(**params) session.get_component("credential_provider").get_provider("assume-role").cache = credentials.JSONFileCache( cli_cache ) from boto3.session import Session params = {} if region: params["region_name"] = region AWS.__session = Session(botocore_session=session, **params)
Example #3
Source File: __init__.py From toil with Apache License 2.0 | 6 votes |
def __init__(self, name, access_key=None, secret_key=None, security_token=None, profile_name=None, **kwargs): """ Create a new BotoCredentialAdapter. """ # TODO: We take kwargs because new boto2 versions have an 'anon' # argument and we want to be future proof if (name == 'aws' or name is None) and access_key is None and not kwargs.get('anon', False): # We are on AWS and we don't have credentials passed along and we aren't anonymous. # We will backend into a boto3 resolver for getting credentials. # Make sure to enable boto3's own caching, so we can share that # cash with pure boto3 code elsewhere in Toil. self._boto3_resolver = create_credential_resolver(Session(profile=profile_name), cache=JSONFileCache()) else: # We will use the normal flow self._boto3_resolver = None # Pass along all the arguments super(BotoCredentialAdapter, self).__init__(name, access_key=access_key, secret_key=secret_key, security_token=security_token, profile_name=profile_name, **kwargs)
Example #4
Source File: authenticate.py From aws-okta-processor with MIT License | 5 votes |
def authenticate(self): cache = JSONFileCache() saml_fetcher = SAMLFetcher( self, cache=cache ) credentials = saml_fetcher.fetch_credentials() return credentials