Skip to content

List AWS accounts under an AWS organization.

Notifications You must be signed in to change notification settings

northwood-labs/aws-account-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Account List

Generates a list of all AWS accounts registered in an AWS Organizations account.

Install as a CLI tool

  1. You must have the Golang toolchain installed first.

    brew install go
  2. 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"
  3. Once you've done everything above, you can use go get.

    go get -u github.com/northwood-labs/aws-account-list

Usage as CLI Tool

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

Usage as Library

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.