AWS Organizations - list accounts for role [boto3]

0

Hi,

We are planning to support for AWS Organizations in our product. We will need to retrieve very often the list of AWS accounts belonging to a given organization. Instead of frequently traversing the organization tree to discover new/deleted accounts (it may be slow), I wonder if there is any boto3 binding or api endpoint to list all organization accounts (and ideally filter by role). Thanks in advance.

Regards

Roberto
已提问 5 个月前204 查看次数
1 回答
2
已接受的回答

Hello.

You can get a list of accounts in Organizations by using list_accounts() described in the following document.
However, this cannot display a list of accounts across organizations, so if you want to cross organizations, you will need to set up cross-account roles, etc.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/organizations/client/list_accounts.html

I think list_children() can be used to list by OU.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/organizations/client/list_children.html

profile picture
专家
已回答 5 个月前
profile picture
专家
已审核 3 小时前
profile pictureAWS
专家
已审核 5 个月前
  • Thank you @Riku - I wonder how the heck I went over this endpoint without noticing... Thanks!

    to list by OU I have found list_accounts_for_parent()

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则