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
preguntada hace 5 meses202 visualizaciones
1 Respuesta
1
Respuesta aceptada

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
EXPERTO
respondido hace 5 meses
profile pictureAWS
EXPERTO
revisado hace 5 meses
  • 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()

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas