forked from gblues/aws-ml-opt-out
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolicy.tf
31 lines (28 loc) · 1.09 KB
/
policy.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
locals {
optOutPolicy = {
services = {
default = {
opt_out_policy = {
"@@assign" = "optOut"
}
}
}
}
my_organization_root = var.create_organization ? "UNUSED" : data.aws_organizations_organization.my_organization[0].roots == null ? "NO-ORGANIZATION-FOUND" : data.aws_organizations_organization.my_organization[0].roots[0].id
}
resource "aws_organizations_policy" "org-policy" {
content = jsonencode(local.optOutPolicy)
name = "OptOutOfAllAIServicesPolicy"
type = "AISERVICES_OPT_OUT_POLICY"
description = "Opt out of all Amazon AI services at an organization level"
}
resource "aws_organizations_policy_attachment" "org-policy-attachment" {
count = var.create_organization ? 1 : 0
policy_id = aws_organizations_policy.org-policy.id
target_id = aws_organizations_organization.organization[0].roots[0].id
}
resource "aws_organizations_policy_attachment" "my-org-policy-attachment" {
count = var.create_organization ? 0 : 1
policy_id = aws_organizations_policy.org-policy.id
target_id = local.my_organization_root
}