@@ -79,6 +79,8 @@ readonly PROD_PROJECT_SERVICES=(
79
79
containerregistry.googleapis.com
80
80
# prod projects host binaries in GCS
81
81
storage-component.googleapis.com
82
+ # prod projects host containers in AR
83
+ artifactregistry.googleapis.com
82
84
)
83
85
84
86
readonly PROD_PROJECT_DISABLED_SERVICES=(
@@ -87,7 +89,9 @@ readonly PROD_PROJECT_DISABLED_SERVICES=(
87
89
)
88
90
89
91
# Regions for prod GCR.
90
- PROD_REGIONS=(us eu asia)
92
+ GCR_PROD_REGIONS=(us eu asia)
93
+ # Regions for prod AR.
94
+ AR_PROD_REGIONS=(asia-east1 asia-south1 asia-northeast1 asia-northeast2 australia-southeast1 europe-north1 europe-southeast1 europe-west1 europe-west2 europe-west4 europe-west8 europe-west9 southamerica-west1 us-central1 us-east1 us-east4 us-east5 us-south1 us-west1 us-west2)
91
95
92
96
# Minimum time we expect to keep prod GCS artifacts.
93
97
PROD_RETENTION=" 10y"
@@ -102,8 +106,8 @@ function ensure_prod_gcr() {
102
106
fi
103
107
local project=" ${1} "
104
108
105
- color 6 " Ensuring prod GCR for regions: ${PROD_REGIONS [*]} "
106
- for region in " ${PROD_REGIONS [@]} " ; do
109
+ color 6 " Ensuring prod GCR for regions: ${GCR_PROD_REGIONS [*]} "
110
+ for region in " ${GCR_PROD_REGIONS [@]} " ; do
107
111
local gcr_bucket=" gs://${region} .artifacts.${project} .appspot.com"
108
112
109
113
color 3 " region: ${region} "
@@ -121,6 +125,33 @@ function ensure_prod_gcr() {
121
125
done 2>&1 | indent
122
126
}
123
127
128
+ # Make a prod AR repository and grant access to it.
129
+ #
130
+ # $1: The GCP project name (GCR names == project names)
131
+ function ensure_prod_ar() {
132
+ if [ $# != 1 ] || [ -z " $1 " ]; then
133
+ echo " ensure_prod_ar(project) requires 1 argument" >&2
134
+ return 1
135
+ fi
136
+ local project=" ${1} "
137
+ local serviceaccount
138
+
139
+ color 6 " Ensuring prod AR registry for locations: ${AR_PROD_REGIONS[*]} "
140
+ for region in " ${AR_PROD_REGIONS[@]} " ; do
141
+
142
+ color 3 " region: ${region} "
143
+ color 6 " Ensuring an AR repo exists in location: ${region} for project: ${project} "
144
+ ensure_ar_repo " ${project} " " ${region} "
145
+
146
+ color 6 " Ensuring GCR admins can admin AR in location: ${region} for project: ${project} "
147
+ empower_ar_admins " ${project} " " ${region} "
148
+
149
+ color 6 " Empowering image promoter with roles/artifactregistry.repoAdmin in project: ${project} "
150
+ serviceaccount=$( svc_acct_email " ${project} " " ${IMAGE_PROMOTER_SVCACCT} " )
151
+ ensure_project_role_binding " ${project} " " serviceAccount:$serviceaccount " " artifactregistry.repoAdmin"
152
+ done 2>&1 | indent
153
+ }
154
+
124
155
# Make a prod GCS bucket and grant access to it. We need whole buckets for
125
156
# this because we want to grant minimal permissions, but there's no concept of
126
157
# permissions on a "subdirectory" of a bucket. If we had a GCS promoter akin
@@ -175,7 +206,7 @@ function empower_group_to_fake_prod() {
175
206
empower_group_as_viewer " ${project} " " ${group} "
176
207
177
208
color 6 " Empowering $group for GCR in $project "
178
- for r in " ${PROD_REGIONS [@]} " ; do
209
+ for r in " ${GCR_PROD_REGIONS [@]} " ; do
179
210
color 3 " region $r "
180
211
empower_group_to_write_gcr " ${group} " " ${project} " " ${r} "
181
212
done
@@ -198,15 +229,18 @@ function ensure_all_prod_projects() {
198
229
color 6 " Ensuring project exists: ${prj} "
199
230
ensure_project " ${prj} "
200
231
201
- color 6 " Ensuring Services to host and analyze aritfacts : ${prj} "
232
+ color 6 " Ensuring Services to host and analyze artifacts : ${prj} "
202
233
ensure_services " ${prj} " " ${PROD_PROJECT_SERVICES[@]} " 2>&1 | indent
203
234
204
235
color 6 " Ensuring disabled services for prod project: ${prj} "
205
236
ensure_disabled_services " ${prj} " " ${PROD_PROJECT_DISABLED_SERVICES[@]} " 2>&1 | indent
206
237
207
- color 6 " Ensuring the GCR repository : ${prj} "
238
+ color 6 " Ensuring the GCR repositories : ${prj} "
208
239
ensure_prod_gcr " ${prj} " 2>&1 | indent
209
240
241
+ color 6 " Ensuring the AR repositories: ${prj} "
242
+ ensure_prod_ar " ${prj} " 2>&1 | indent
243
+
210
244
color 6 " Ensuring the GCS bucket: gs://${prj} "
211
245
ensure_prod_gcs_bucket " ${prj} " " gs://${prj} " 2>&1 | indent
212
246
done
@@ -289,7 +323,7 @@ function ensure_all_prod_special_cases() {
289
323
# real $PRODBAK_PROJECT). We don't want this same power for the non-test
290
324
# backup system, so a compromised promoter can't nuke backups.
291
325
color 6 " Empowering backup-test-prod promoter to backup-test-prod GCR"
292
- for r in " ${PROD_REGIONS [@]} " ; do
326
+ for r in " ${GCR_PROD_REGIONS [@]} " ; do
293
327
color 3 " region $r "
294
328
empower_svcacct_to_write_gcr \
295
329
" $( svc_acct_email " ${GCR_BACKUP_TEST_PRODBAK_PROJECT} " " ${IMAGE_PROMOTER_SVCACCT} " ) " \
0 commit comments