Generates a list of all AWS accounts registered in an AWS Organizations account.
-
You must have the Golang toolchain installed first.
brew install go
-
Add
$GOPATH/bin
to your$PATH
environment variable. By default (i.e., without configuration),$GOPATH
is defined as$HOME/go
.export PATH="$PATH:$GOPATH/bin"
-
Once you've done everything above, you can use
go get
.go get -u github.com/northwood-labs/aws-account-list
Examples assume the use of AWS Vault and AWS Identity Center.
Gets a list of AWS accounts that are part of the AWS Organization as JSON.
aws-account-list --help
Read directly from the AWS Organizations management account.
aws-vault exec management-account -- aws-account-list
Assume the AWS_ORG_ROLE
IAM role first, then read the AWS Organizations management account using that IAM role.
AWS_ORG_ROLE="arn:aws:iam::0123456789012:role/OrganizationReadOnlyAccess"
aws-vault exec management-account -- aws-account-list
This can also be used as a library in your own applications for generating a list in-memory. The library should fetch data for accounts asynchronously for better performance, but does not yet. This has been tested on AWS Organizations up to ~200 accounts.
import "github.com/northwood-labs/aws-account-list/accountlist"
See main.go
, which implements this library to produce this very same CLI tool.