To fix hashicorp/terraform-provider-aws#17656 I created a simple script using external
data source for Terraform.
Using it I'm able, for example, to list all ACTIVE accounts with IDs or emails.
local {
accounts_emails = split(",", data.external.accounts.result.Outputs)