简体   繁体   English

Boto3 组织列出组织内的所有活动帐户

[英]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.作为标题 state 我正在尝试列出 aws 组织中的所有活动帐户,同时还使用以下 python 和 boto3 调用对我的帐户列表进行分页。

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. StartingToken 是从 AWS 接收的令牌。 It appears your adding 'string'看来您正在添加“字符串”

See: How to use Boto3 pagination请参阅: 如何使用 Boto3 分页

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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