Skip to content

Commit 1223413

Browse files
Android Build Filesystem (ABFS) Teamsce-taid
authored andcommitted
Refactor: Move Cloud Workstation image build resources to cicd_pipelines.
This change centralizes the Cloud Build trigger and Cloud Scheduler job for Cloud Workstation custom image builds within the `cicd_pipelines` module. The `cicd_workstations` module now focuses solely on deploying the Workstation clusters and configurations. The `apps` variable in `cicd_pipelines` is updated to include `workstation_config` details, and the necessary APIs and IAM permissions are conditionally enabled. PiperOrigin-RevId: 802086332
1 parent c580234 commit 1223413

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

examples/simple/workstations.tf

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
module "cicd_pipelines" {
16-
count = var.create_cloud_workstation_resources ? 1 : 0
17-
18-
source = "github.com/GoogleCloudPlatform/cicd-foundation//infra/modules/cicd_pipelines?ref=v2.1.0"
19-
20-
project_id = data.google_project.project.project_id
21-
apps = {
22-
for k in keys(var.cws_custom_images) : k => {
23-
runtime = "workstations"
24-
}
25-
}
26-
}
27-
2815
module "workstations" {
2916
count = var.create_cloud_workstation_resources ? 1 : 0
3017

@@ -34,27 +21,24 @@ module "workstations" {
3421
cws_scopes = var.cws_scopes
3522
cws_clusters = var.cws_clusters
3623
cws_configs = var.cws_configs
37-
custom_images = {
38-
for k, v in module.cicd_pipelines[0].cloud_build_trigger_trigger_id :
39-
k => merge(
40-
{
41-
ci_trigger = v
42-
},
43-
try({ scheduler_region = var.cws_custom_images[k]["scheduler_region"] }, {}),
44-
try({ ci_schedule = var.cws_custom_images[k]["ci_schedule"] }, {})
45-
)
46-
}
47-
cloud_build_service_account_id = module.cicd_pipelines[0].cloud_build_service_account_id
4824
}
4925

50-
resource "google_artifact_registry_repository_iam_binding" "reader" {
51-
count = var.create_cloud_workstation_resources ? 1 : 0
26+
module "cicd_pipelines" {
27+
count = var.create_cloud_workstation_resources && length(var.cws_custom_images) > 0 ? 1 : 0
28+
29+
source = "../../../../cloud_cicd_foundation/infra/modules/cicd_pipelines"
5230

53-
project = module.cicd_pipelines[0].artifact_registry_repository.project
54-
location = module.cicd_pipelines[0].artifact_registry_repository.location
55-
repository = module.cicd_pipelines[0].artifact_registry_repository.id
56-
role = "roles/artifactregistry.reader"
57-
members = [
31+
project_id = data.google_project.project.project_id
32+
apps = {
33+
for k, v in var.cws_custom_images : k => {
34+
runtime = "workstations"
35+
workstation_config = {
36+
scheduler_region = v.scheduler_region
37+
ci_schedule = v.ci_schedule
38+
}
39+
}
40+
}
41+
artifact_registry_readers = [
5842
"serviceAccount:${module.workstations[0].cws_service_account_email}"
5943
]
6044
}

0 commit comments

Comments
 (0)