Skip to content

Commit 1427b41

Browse files
committed
feat: resource creation defaults to root if not specified
1 parent 68fd842 commit 1427b41

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

modules/account/data.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "aws_organizations_organization" "org" {}

modules/account/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "aws_organizations_account" "member_account" {
22
name = var.name
33
email = var.email
4-
parent_id = var.parent_id
4+
parent_id = var.parent_id != "" ? var.parent_id : data.aws_organizations_organization.org.roots[0].id
55
iam_user_access_to_billing = var.iam_user_access_to_billing
66
tags = var.tags
77
close_on_deletion = var.close_on_deletion
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "aws_organizations_organization" "org" {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_organizations_organizational_unit" "org_unit" {
22
name = var.name
3-
parent_id = var.parent_id
3+
parent_id = var.parent_id != "" ? var.parent_id : data.aws_organizations_organization.org.roots[0].id
44
tags = var.tags
55
}

0 commit comments

Comments
 (0)