diff options
author | Daniel Lindsley <daniel@toastdriven.com> | 2014-03-07 17:09:18 -0800 |
---|---|---|
committer | Daniel Lindsley <daniel@toastdriven.com> | 2014-03-07 17:09:18 -0800 |
commit | caa048c4f142c93c6c142bc189afe2cbe53d13d5 (patch) | |
tree | 43de41b0675f247fa40aabb75fcbeac5deb5c3b1 /boto/iam | |
parent | 372926f29bf78f2179d348c74fe9949c5e086a86 (diff) | |
download | boto-caa048c4f142c93c6c142bc189afe2cbe53d13d5.tar.gz |
Fixed ``get_signin_url`` behavior.
This is pretty much broken right now. This improves it & should make cn-north-1 work correctly now as well.
Diffstat (limited to 'boto/iam')
-rw-r--r-- | boto/iam/connection.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/boto/iam/connection.py b/boto/iam/connection.py index e697b5ed..c6ee3007 100644 --- a/boto/iam/connection.py +++ b/boto/iam/connection.py @@ -1027,13 +1027,35 @@ class IAMConnection(AWSQueryConnection): :param service: Default service to go to in the console. """ alias = self.get_account_alias() + if not alias: raise Exception('No alias associated with this account. Please use iam.create_account_alias() first.') + resp = alias.get('list_account_aliases_response', {}) + result = resp.get('list_account_aliases_result', {}) + aliases = result.get('account_aliases', []) + + if not len(aliases): + raise Exception('No alias associated with this account. Please use iam.create_account_alias() first.') + + # We'll just use the first one we find. + alias = aliases[0] + if self.host == 'iam.us-gov.amazonaws.com': - return "https://%s.signin.amazonaws-us-gov.com/console/%s" % (alias, service) + return "https://%s.signin.amazonaws-us-gov.com/console/%s" % ( + alias, + service + ) + elif self.host.endswith('amazonaws.com.cn'): + return "https://%s.signin.amazonaws.cn/console/%s" % ( + alias, + service + ) else: - return "https://%s.signin.aws.amazon.com/console/%s" % (alias, service) + return "https://%s.signin.aws.amazon.com/console/%s" % ( + alias, + service + ) def get_account_summary(self): """ |