我试图编写代码,它将传递 AWS Organizations 中的账户列表,这些账户SUSPENDED
将打印ACTIVE
账户的逻辑输出。代码片段是:
def get_accounts(role_arn) -> list:
'''Appends all the accounts listed in operations into ACCOUNTS'''
accounts = []
creds = get_aws_key_and_token(role_arn)
sess = session.Session(
aws_access_key_id=creds['AccessKeyId'],
aws_secret_access_key=creds['SecretAccessKey'],
aws_session_token=creds['SessionToken']
)
accounts = {}
org = sess.client('organizations')
paginator = org.get_paginator('list_accounts')
page_iterator = paginator.paginate()
for page in page_iterator:
for acct in page['Accounts']:
accounts[acct['Id']] = acct['Name']
return accounts
有人可以帮我添加该功能吗?
谢谢