Would be nice to have a data resource to list all accounts under the organization
https://docs.aws.amazon.com/cli/latest/reference/organizations/list-accounts.html
See also:
https://github.com/terraform-providers/terraform-provider-aws/issues/571
https://github.com/terraform-providers/terraform-provider-aws/pull/2530
https://github.com/terraform-providers/terraform-provider-aws/pull/3604
https://github.com/terraform-providers/terraform-provider-aws/pull/4384
https://github.com/terraform-providers/terraform-provider-aws/pull/4688
https://github.com/terraform-providers/terraform-provider-aws/pull/7038
In addition to tracking just support for fetching all Organization account IDs, this issue will be used for tracking adding the aws_organizations_organization
data source in general as part of closing #571 shortly. 👍 There is a high probability that both will be implemented under the same data source.
Would love to see aws_organizations_organization
data source, since being able to to extract Organization ID from any child account, allows to leverage the global policy condition key aws:PrincipalOrgID
in various resource (e.g. S3) and IAM Role trust policies.
Support for a new aws_organizations_organization
data source has been merged and will release with version 2.21.0 of the Terraform AWS Provider, in about a week. 🎉
This new data source has a few modes of operation:
aws_organizations_organization
resource including all member account information such as account ARNs and account IDsWe want to thank everyone for being patient through this whole process while we evaluated use cases and special thanks to @alucillo, @brandonstevens, @breser, @nirhaas, and @scottwinkler for their various contributions with this functionality!
This has been released in version 2.21.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests, documentation updates, or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
Support for a new
aws_organizations_organization
data source has been merged and will release with version 2.21.0 of the Terraform AWS Provider, in about a week. 🎉This new data source has a few modes of operation:
aws_organizations_organization
resource including all member account information such as account ARNs and account IDsWe want to thank everyone for being patient through this whole process while we evaluated use cases and special thanks to @alucillo, @brandonstevens, @breser, @nirhaas, and @scottwinkler for their various contributions with this functionality!