Skip to content

Commit e17dc02

Browse files
authored
Merge pull request #18 from infraspecdev/refactor/policy
feat: Support policy attachment by default in sub module
2 parents 335b7cd + 66e0140 commit e17dc02

File tree

11 files changed

+18
-137
lines changed

11 files changed

+18
-137
lines changed

examples/create-standard-organization-policies/main.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,5 @@ module "tag_policy" {
1515
description = local.tag_policy_description
1616
type = local.tag_policy_type
1717
tags = local.default_tags
18-
}
19-
20-
21-
module "attach_tag_policy" {
22-
source = "../../modules/policy_attachment"
23-
policy_id = module.tag_policy.aws_organizations_policy_id
24-
target_id = local.tag_policy_taget_id
18+
target_id = local.tag_policy_taget_id
2519
}

modules/policy/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ resource "aws_organizations_policy" "this" {
66
type = var.type
77
tags = var.tags
88
}
9+
10+
resource "aws_organizations_policy_attachment" "this" {
11+
policy_id = aws_organizations_policy.this.id
12+
target_id = var.target_id
13+
skip_destroy = var.skip_destroy
14+
}

modules/policy/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ variable "tags" {
3636
type = map(string)
3737
default = {}
3838
}
39+
40+
variable "target_id" {
41+
description = "(Required) The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to."
42+
type = string
43+
}

modules/policy_attachment/.header.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

modules/policy_attachment/README.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

modules/policy_attachment/main.tf

Lines changed: 0 additions & 5 deletions
This file was deleted.

modules/policy_attachment/outputs.tf

Whitespace-only changes.

modules/policy_attachment/variables.tf

Lines changed: 0 additions & 15 deletions
This file was deleted.

modules/policy_attachment/versions.tf

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/policy_attachment_unit-tests.tftest.hcl.hcl

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)