(session, **kwargs)
| 17 | |
| 18 | |
| 19 | def inject_assume_role_provider_cache(session, **kwargs): |
| 20 | try: |
| 21 | cred_chain = session.get_component('credential_provider') |
| 22 | except ProfileNotFound: |
| 23 | # If a user has provided a profile that does not exist, |
| 24 | # trying to retrieve components/config on the session |
| 25 | # will raise ProfileNotFound. Sometimes this is invalid: |
| 26 | # |
| 27 | # "ec2 describe-instances --profile unknown" |
| 28 | # |
| 29 | # and sometimes this is perfectly valid: |
| 30 | # |
| 31 | # "configure set region us-west-2 --profile brand-new-profile" |
| 32 | # |
| 33 | # Because we can't know (and don't want to know) whether |
| 34 | # the customer is trying to do something valid, we just |
| 35 | # immediately return. If it's invalid something else |
| 36 | # up the stack will raise ProfileNotFound, otherwise |
| 37 | # the configure (and other) commands will work as expected. |
| 38 | LOG.debug( |
| 39 | "ProfileNotFound caught when trying to inject " |
| 40 | "assume-role cred provider cache. Not configuring " |
| 41 | "JSONFileCache for assume-role." |
| 42 | ) |
| 43 | return |
| 44 | assume_role_provider = cred_chain.get_provider('assume-role') |
| 45 | assume_role_provider.cache = JSONFileCache(CACHE_DIR) |
| 46 | web_identity_provider = cred_chain.get_provider( |
| 47 | 'assume-role-with-web-identity' |
| 48 | ) |
| 49 | web_identity_provider.cache = JSONFileCache(CACHE_DIR) |
nothing calls this directly
no test coverage detected