Skip to content

Instantly share code, notes, and snippets.

@alastairhm
Created March 6, 2020 16:37
Show Gist options
  • Save alastairhm/8b6c4d48179df1a1725eaf106309a8a7 to your computer and use it in GitHub Desktop.
Save alastairhm/8b6c4d48179df1a1725eaf106309a8a7 to your computer and use it in GitHub Desktop.
Return members' AccountID and Email of AWS Organization account
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