-
Notifications
You must be signed in to change notification settings - Fork 0
/
policies.tf
187 lines (166 loc) · 6.54 KB
/
policies.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
locals {
organization_id = var.parent_folder != "" ? null : var.org_id
folder_id = var.parent_folder != "" ? var.parent_folder : null
policy_for = var.parent_folder != "" ? "folder" : "organization"
}
/******************************************
Compute org policies
*******************************************/
module "org_disable_nested_virtualization" {
count = var.org_disable_nested_virtualization ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/compute.disableNestedVirtualization"
}
module "org_disable_serial_port_access" {
count = var.org_disable_serial_port_access ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/compute.disableSerialPortAccess"
}
module "org_compute_disable_guest_attributes_access" {
count = var.org_compute_disable_guest_attributes_access ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/compute.disableGuestAttributesAccess"
}
module "org_vm_external_ip_access" {
count = var.org_vm_external_ip_access ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "list"
enforce = "true"
constraint = "constraints/compute.vmExternalIpAccess"
}
module "org_skip_default_network" {
count = var.org_skip_default_network ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/compute.skipDefaultNetworkCreation"
}
module "org_shared_vpc_lien_removal" {
count = var.org_shared_vpc_lien_removal ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/compute.restrictXpnProjectLienRemoval"
}
module "org_shared_require_os_login" {
count = var.org_shared_require_os_login ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/compute.requireOsLogin"
}
module "org_shared_resource_locations" {
count = var.org_shared_resource_locations ? 1 : 0
source = "terraform-google-modules/org-policy/google"
policy_for = "folder"
folder_id = local.folder_id
constraint = "constraints/gcp.resourceLocations"
policy_type = "list"
enforce = null
allow = var.allowed_regions
allow_list_length = 1
}
/******************************************
Cloud SQL
*******************************************/
module "org_cloudsql_external_ip_access" {
count = var.org_cloudsql_external_ip_access ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/sql.restrictPublicIp"
}
/******************************************
IAM
*******************************************/
module "org_domain_restricted_sharing" {
count = var.org_domain_restricted_sharing ? 1 : 0
source = "terraform-google-modules/org-policy/google//modules/domain_restricted_sharing"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
domains_to_allow = var.domains_to_allow
}
module "org_disable_sa_key_creation" {
count = var.org_disable_sa_key_creation ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/iam.disableServiceAccountKeyCreation"
}
module "org_disable_automatic_iam_grants_on_default_service_accounts" {
count = var.org_disable_automatic_iam_grants_on_default_service_accounts ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/iam.automaticIamGrantsForDefaultServiceAccounts"
}
/******************************************
Storage
*******************************************/
module "org_enforce_bucket_level_access" {
count = var.org_enforce_bucket_level_access ? 1 : 0
source = "terraform-google-modules/org-policy/google"
version = "~> 5.0"
organization_id = local.organization_id
folder_id = local.folder_id
policy_for = local.policy_for
policy_type = "boolean"
enforce = "true"
constraint = "constraints/storage.uniformBucketLevelAccess"
}
/******************************************
Access Context Manager Policy
*******************************************/
resource "google_access_context_manager_access_policy" "access_policy" {
count = var.create_access_context_manager_access_policy ? 1 : 0
parent = "organizations/${var.org_id}"
title = "default policy"
}