-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Flaconi/OPS-6301-scp-module
OPS-6301: Terraform Module for SCP
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Create an AWS Organization policy for each policy template | ||
resource "aws_organizations_policy" "scp" { | ||
for_each = { for policy in var.policies : policy.name => policy } | ||
|
||
name = each.key | ||
description = each.value.description | ||
content = templatefile(lookup(each.value, "file"), {}) | ||
} | ||
|
||
resource "aws_organizations_policy_attachment" "attach_scp" { | ||
for_each = { | ||
for policy in aws_organizations_policy.scp : | ||
policy.name => policy | ||
} | ||
policy_id = each.value.id | ||
target_id = flatten([for p in var.policies : p.target_ids if p.name == each.key])[0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "policy_arns" { | ||
value = { for k, v in aws_organizations_policy.scp : k => v.arn } | ||
description = "Map of policy ARNs." | ||
} | ||
|
||
output "policy_ids" { | ||
value = { for k, v in aws_organizations_policy.scp : k => v.id } | ||
description = "Map of policy IDs." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "policies" { | ||
description = "List of policies with their details" | ||
type = list(object({ | ||
name = string | ||
file = string | ||
target_ids = list(string) | ||
description = string | ||
})) | ||
} |