2014-09-03 28 views
3

我有一個密鑰和祕密密鑰,並想打電話給boto獲取帳戶名稱。 我可以獲得帳戶ID,但aws帳戶名稱是一個謎。你能從boto獲得aws帳戶名嗎?

+0

請檢查答案http://stackoverflow.com/questions/36709461/get-aws-account-id-from-boto – Montaro 2016-12-14 16:04:57

+0

看來,這個問題明確提到boto2,因爲當問這個問題時boto3沒有出現。只是爲了好玩,我查了一下,最初的提交實際上是在發佈這個問題後6小時:https://github.com/boto/boto3/commit/a33e1f8595e8d4cf70b8d5c0b1a7657124adc6a2 :) – Jake 2017-10-05 15:06:52

回答

1

Get AWS Account ID from Boto

id = boto3.client('sts').get_caller_identity().get('Account') 

那麼這裏

name = boto3.client('organizations').describe_account(AccountId=id).get('Account').get('Name') 
相關問題