简体   繁体   中英

Boto3 Organizations list all active accounts within an Org

As the title state I am trying to list all active accounts in an aws organization while also paginating my account list using the following python and boto3 call.

client = boto3.client(
    "organizations",
    aws_access_key_id=credentials["AccessKeyId"],
    aws_secret_access_key=credentials["SecretAccessKey"],
    aws_session_token=credentials["SessionToken"],
)
paginator = client.get_paginator('list_accounts')
response_iterator = paginator.paginate(
PaginationConfig={
    'MaxItems': 1000,
    'PageSize': 123,
    'StartingToken': 'string'})
for page in response_iterator:        
    for acct in page['Accounts']:
        print(acct)

StartingToken is a token that received from AWS. It appears your adding 'string'

See: How to use Boto3 pagination

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM