summaryrefslogtreecommitdiff
path: root/boto/provider.py
diff options
context:
space:
mode:
Diffstat (limited to 'boto/provider.py')
-rw-r--r--boto/provider.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/boto/provider.py b/boto/provider.py
index c587e020..8a990ed1 100644
--- a/boto/provider.py
+++ b/boto/provider.py
@@ -275,10 +275,16 @@ class Provider(object):
boto.log.debug("Retrieving credentials from metadata server.")
from boto.utils import get_instance_metadata
timeout = config.getfloat('Boto', 'metadata_service_timeout', 1.0)
- metadata = get_instance_metadata(timeout=timeout, num_retries=1)
- # I'm assuming there's only one role on the instance profile.
- if metadata and 'iam' in metadata:
- security = metadata['iam']['security-credentials'].values()[0]
+ attempts = config.getint('Boto', 'metadata_service_num_attempts', 1)
+ # The num_retries arg is actually the total number of attempts made,
+ # so the config options is named *_num_attempts to make this more
+ # clear to users.
+ metadata = get_instance_metadata(
+ timeout=timeout, num_retries=attempts,
+ data='meta-data/iam/security-credentials')
+ if metadata:
+ # I'm assuming there's only one role on the instance profile.
+ security = metadata.values()[0]
self._access_key = security['AccessKeyId']
self._secret_key = self._convert_key_to_str(security['SecretAccessKey'])
self._security_token = security['Token']