Created
March 6, 2020 16:37
-
-
Save alastairhm/8b6c4d48179df1a1725eaf106309a8a7 to your computer and use it in GitHub Desktop.
Return members' AccountID and Email of AWS Organization account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
client = boto3.client('organizations') | |
response = client.list_accounts( | |
) | |
if "Accounts" in response: | |
for account in response['Accounts']: | |
print("\"%s\",\"%s\"" %(account['Id'],account['Email'])) | |
while "NextToken" in response: | |
response = client.list_accounts( | |
NextToken = response['NextToken'] | |
) | |
for account in response['Accounts']: | |
print("\"%s\",\"%s\"" %(account['Id'],account['Email'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment