mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add fallback check for IAM role temp creds (#40240)
* Add fallback check for IAM role temp creds
This commit is contained in:
parent
6227c2ac75
commit
d5a5e37fcf
1 changed files with 7 additions and 0 deletions
|
@ -451,6 +451,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
self.aws_secret_access_key = self._options.get('aws_secret_access_key')
|
self.aws_secret_access_key = self._options.get('aws_secret_access_key')
|
||||||
self.aws_security_token = self._options.get('aws_security_token')
|
self.aws_security_token = self._options.get('aws_security_token')
|
||||||
|
|
||||||
|
if not self.boto_profile and not (self.aws_access_key_id and self.aws_secret_access_key):
|
||||||
|
session = botocore.session.get_session()
|
||||||
|
if session.get_credentials() is not None:
|
||||||
|
self.aws_access_key_id = session.get_credentials().access_key
|
||||||
|
self.aws_secret_access_key = session.get_credentials().secret_key
|
||||||
|
self.aws_security_token = session.get_credentials().token
|
||||||
|
|
||||||
if not self.boto_profile and not (self.aws_access_key_id and self.aws_secret_access_key):
|
if not self.boto_profile and not (self.aws_access_key_id and self.aws_secret_access_key):
|
||||||
raise AnsibleError("Insufficient boto credentials found. Please provide them in your "
|
raise AnsibleError("Insufficient boto credentials found. Please provide them in your "
|
||||||
"inventory configuration file or set them as environment variables.")
|
"inventory configuration file or set them as environment variables.")
|
||||||
|
|
Loading…
Reference in a new issue