NEW: account-list module
This commit is contained in:
parent
d7d12301d8
commit
89a45a747e
16
modules/util/account-list/README.md
Normal file
16
modules/util/account-list/README.md
Normal file
@ -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")
|
||||||
|
}
|
||||||
|
```
|
2
modules/util/account-list/main.tf
Normal file
2
modules/util/account-list/main.tf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
data "aws_organizations_organization" "org" {}
|
||||||
|
|
3
modules/util/account-list/outputs.tf
Normal file
3
modules/util/account-list/outputs.tf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
output accounts {
|
||||||
|
value = zipmap(data.aws_organizations_organization.org.accounts[*].name, data.aws_organizations_organization.org.accounts[*].id)
|
||||||
|
}
|
10
modules/util/account-list/provider.tf
Normal file
10
modules/util/account-list/provider.tf
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = "~> 1.2.5"
|
||||||
|
required_providers {
|
||||||
|
aws = {
|
||||||
|
source = "hashicorp/aws"
|
||||||
|
version = "~> 4.22"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user