-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathdevops.hcl
More file actions
254 lines (246 loc) · 8.01 KB
/
devops.hcl
File metadata and controls
254 lines (246 loc) · 8.01 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
schema = {
title = "Devops Recipe"
additionalProperties = false
required = [
"admins_group",
"project",
]
properties = {
parent_type = {
description = <<EOF
Type of parent GCP resource to apply the policy.
Must be one of 'organization' or 'folder'.
EOF
type = "string"
pattern = "^organization|folder$"
}
parent_id = {
description = <<EOF
ID of parent GCP resource to apply the policy.
Can be one of the organization ID or folder ID according to parent_type.
EOF
type = "string"
pattern = "^[0-9]{8,25}$"
}
billing_account = {
description = "ID of billing account to attach to this project."
type = "string"
}
project = {
description = "Config for the project to host devops resources such as remote state and CICD."
type = "object"
additionalProperties = false
required = [
"project_id",
"owners_group",
]
properties = {
project_id = {
description = "ID of project."
type = "string"
pattern = "^[a-z][a-z0-9\\-]{4,28}[a-z0-9]$"
}
owners_group = {
description = <<EOF
Group which will be given owner access to the project.
It will be created if 'exists' is false.
NOTE: By default, the creating user will be the owner of the project.
However, this group will own the project going forward. Make sure to include
yourselve in the group,
EOF
type = "object"
additionalProperties = false
required = [
"id",
]
properties = {
id = {
description = "Email address of the group."
type = "string"
}
exists = {
description = "Whether or not the group exists already. Default to 'false'."
type = "boolean"
}
customer_id = {
description = <<EOF
Customer ID of the organization to create the group in.
See <https://cloud.google.com/resource-manager/docs/organization-policy/restricting-domains#retrieving_customer_id>
for how to obtain it.
EOF
type = "string"
}
description = {
description = "Description of the group."
type = "string"
}
display_name = {
description = "Display name of the group."
type = "string"
}
owners = {
description = "Owners of the group."
type = "array"
items = {
type = "string"
}
}
# Due to limitations in the underlying module, managers and members
# are not supported and should be configured in the Google Workspace
# Admin console.
# managers = {
# description = "Managers of the group."
# type = "array"
# items = {
# type = "string"
# }
# }
# members = {
# description = "Members of the group."
# type = "array"
# items = {
# type = "string"
# }
# }
}
}
apis = {
description = <<EOF
List of APIs enabled in the devops project.
NOTE: If a CICD is deployed within this project, then the APIs of
all resources managed by the CICD must be listed here
(even if the resources themselves are in different projects).
EOF
}
labels = {
description = "Map of labels for this project"
type = "object"
patternProperties = {
".+" = { type = "string" }
}
}
}
}
state_bucket = {
description = "Name of Terraform remote state bucket."
type = "string"
}
storage_location = {
description = "Location of state bucket."
type = "string"
}
admins_group = {
description = <<EOF
Group which will be given admin access to the folder or organization.
It will be created if 'exists' is false.
EOF
type = "object"
additionalProperties = false
required = [
"id",
]
properties = {
id = {
description = "Email address of the group."
type = "string"
}
exists = {
description = "Whether or not the group exists already. Default to 'false'."
type = "boolean"
}
customer_id = {
description = <<EOF
Customer ID of the organization to create the group in.
See <https://cloud.google.com/resource-manager/docs/organization-policy/restricting-domains#retrieving_customer_id>
for how to obtain it.
EOF
type = "string"
}
description = {
description = "Description of the group."
type = "string"
}
display_name = {
description = "Display name of the group."
type = "string"
}
owners = {
description = "Owners of the group."
type = "array"
items = {
type = "string"
}
}
# Due to limitations in the underlying module, managers and members
# are not supported and should be configured in the Google Workspace
# Admin console.
# managers = {
# description = "Managers of the group."
# type = "array"
# items = {
# type = "string"
# }
# }
# members = {
# description = "Members of the group."
# type = "array"
# items = {
# type = "string"
# }
# }
}
}
enable_gcs_backend = {
description = <<EOF
Whether to enable GCS backend for the devops module.
Defaults to false.
Since the devops module creates the state bucket, it cannot back up
the state to the GCS bucket on the first module. Thus, this field
should be set to false initially.
After the devops module has been applied once and the state bucket
exists, the user should set this to true and regenerate the configs.
To migrate the state from local to GCS, run `terraform init` on the
module.
EOF
type = "boolean"
}
terraform_addons = {
description = <<EOF
Additional Terraform configuration for the devops deployment.
For schema see ./deployment.hcl.
EOF
}
}
}
template "git" {
component_path = "../components/git"
output_path = ".."
}
template "deployment" {
recipe_path = "./deployment.hcl"
passthrough = [
"terraform_addons",
]
data = {
# The default value for `enable_gcs_backend` when not specified in the "deployment"
# recipe is set to `true`, while in the "devops" recipe, the default value when not
# specified should be `false`.
enable_gcs_backend = {{get . "enable_gcs_backend" false}}
}
}
template "devops" {
component_path = "../components/devops"
}