initial commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# acocunt-list module
|
||||
This module returns a list of accounts by querying the aws_organizations_organiation datasource. It returns an accounts map like this
|
||||
|
||||
```
|
||||
{
|
||||
account-name-1 = "111111111111"
|
||||
account-name-2 = "111111111111"
|
||||
}
|
||||
```
|
||||
|
||||
In the root module, query the account id like this
|
||||
```terraform
|
||||
output result {
|
||||
value = lookup(module.account-list.accounts, "account-name-1")
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,2 @@
|
||||
data "aws_organizations_organization" "org" {}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
output accounts {
|
||||
value = zipmap(data.aws_organizations_organization.org.accounts[*].name, data.aws_organizations_organization.org.accounts[*].id)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
terraform {
|
||||
required_version = "~> 1.2.5"
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "~> 4.22"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user