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
32
33
|
# Service Control Policies =====================================================
# Creates SCP documents and attaches them to their target OUs or accounts.
# SCPs =========================================================================
resource "aws_organizations_policy" "this" {
for_each = var.policies
name = each.value.name
description = each.value.description
content = each.value.content
type = "SERVICE_CONTROL_POLICY"
tags = local.policy_tags[each.key]
}
# SCP attachments: managed -----------------------------------------------------
resource "aws_organizations_policy_attachment" "this" {
for_each = local.policy_target_map
policy_id = aws_organizations_policy.this[each.value.policy_key].id
target_id = each.value.target
}
# SCP attachments: existing ----------------------------------------------------
resource "aws_organizations_policy_attachment" "existing" {
for_each = local.attachment_target_map
policy_id = each.value.policy_id
target_id = each.value.target
}
|