File tree Expand file tree Collapse file tree 6 files changed +57
-14
lines changed Expand file tree Collapse file tree 6 files changed +57
-14
lines changed Original file line number Diff line number Diff line change 17
17
module "cai_monitoring" {
18
18
source = " ../../modules/cai-monitoring"
19
19
20
- org_id = local. org_id
21
- billing_account = local. billing_account
22
- project_id = module. scc_notifications . project_id
23
- location = local. default_region
20
+ org_id = local. org_id
21
+ billing_account = local. billing_account
22
+ project_id = module. scc_notifications . project_id
23
+ location = local. default_region
24
+ build_service_account = " projects/${ module . scc_notifications . project_id } /serviceAccounts/${ google_service_account . cai_monitoring_builder . email } "
24
25
}
Original file line number Diff line number Diff line change @@ -188,3 +188,14 @@ resource "google_project_iam_member" "kms_admin" {
188
188
role = " roles/cloudkms.viewer"
189
189
member = " group:${ var . gcp_groups . kms_admin } "
190
190
}
191
+
192
+ resource "google_project_iam_member" "cai_monitoring_builder" {
193
+ project = module. scc_notifications . project_id
194
+ for_each = toset ([
195
+ " roles/logging.logWriter" ,
196
+ " roles/storage.objectViewer" ,
197
+ " roles/artifactregistry.writer" ,
198
+ ])
199
+ role = each. key
200
+ member = " serviceAccount:${ google_service_account . cai_monitoring_builder . email } "
201
+ }
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright 2024 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ resource "google_service_account" "cai_monitoring_builder" {
18
+ project = module. scc_notifications . project_id
19
+ account_id = " cai-monitoring-builder"
20
+ description = " Cloud Functions has an underlying dependency on Cloud Build and other services. This service account allows Cloud Build to provision the necessary resources for Cloud Functions."
21
+ create_ignore_already_exists = true
22
+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ module "secure_cai_notification" {
23
23
| Name | Description | Type | Default | Required |
24
24
| ------| -------------| ------| ---------| :--------:|
25
25
| billing\_ account | The ID of the billing account to associate projects with. | ` string ` | n/a | yes |
26
+ | build\_ service\_ account | Cloud Function Build Service Account Id. This is The fully-qualified name of the service account to be used for building the container. | ` string ` | n/a | yes |
26
27
| enable\_ cmek | The KMS Key to Encrypt Artifact Registry repository, Cloud Storage Bucket and Pub/Sub. | ` bool ` | ` false ` | no |
27
28
| encryption\_ key | The KMS Key to Encrypt Artifact Registry repository, Cloud Storage Bucket and Pub/Sub. | ` string ` | ` null ` | no |
28
29
| labels | Labels to be assigned to resources. | ` map(any) ` | ` {} ` | no |
Original file line number Diff line number Diff line change @@ -142,16 +142,17 @@ resource "google_scc_source" "cai_monitoring" {
142
142
// Cloud Function
143
143
module "cloud_function" {
144
144
source = " GoogleCloudPlatform/cloud-functions/google"
145
- version = " ~> 0.5"
146
-
147
- function_name = " caiMonitoring"
148
- description = " Check on the Organization for members (users, groups and service accounts) that contains the IAM roles listed."
149
- project_id = var. project_id
150
- labels = var. labels
151
- function_location = var. location
152
- runtime = " nodejs20"
153
- entrypoint = " caiMonitoring"
154
- docker_repository = google_artifact_registry_repository. cloudfunction . id
145
+ version = " ~> 0.6"
146
+
147
+ function_name = " caiMonitoring"
148
+ description = " Check on the Organization for members (users, groups and service accounts) that contains the IAM roles listed."
149
+ project_id = var. project_id
150
+ labels = var. labels
151
+ function_location = var. location
152
+ runtime = " nodejs20"
153
+ entrypoint = " caiMonitoring"
154
+ docker_repository = google_artifact_registry_repository. cloudfunction . id
155
+ build_service_account = var. build_service_account
155
156
156
157
storage_source = {
157
158
bucket = module.cloudfunction_source_bucket.name
Original file line number Diff line number Diff line change @@ -70,3 +70,10 @@ variable "random_suffix" {
70
70
type = bool
71
71
default = true
72
72
}
73
+
74
+ variable "build_service_account" {
75
+ description = " Cloud Function Build Service Account Id. This is The fully-qualified name of the service account to be used for building the container."
76
+ type = string
77
+ }
78
+
79
+
You can’t perform that action at this time.
0 commit comments