1+ # Copyright 2021 Google LLC
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+
116steps :
217
318- id : ' Add a Secret to Secret Manager'
@@ -12,9 +27,13 @@ steps:
1227 sed -i "s/\"DB_USER\": \"postgres\"/\"DB_USER\": \"${_DB_USER}\"/" postgres-secrets.json
1328
1429 ./test/retry.sh "gcloud secrets create ${_SERVICE}-secrets \
15- --replication-policy=" automatic" \
30+ --replication-policy=automatic \
1631 --data-file=postgres-secrets.json"
1732
33+ ./test/retry.sh "gcloud secrets add-iam-policy-binding ${_SERVICE}-secrets \
34+ --member=serviceAccount:${_SERVICE_ACCOUNT} \
35+ --role=roles/secretmanager.secretAccessor"
36+
1837 - id : ' Build Container Image'
1938 name : ' gcr.io/cloud-builders/docker'
2039 entrypoint : ' /bin/bash'
@@ -37,11 +56,11 @@ steps:
3756 args :
3857 - ' -c'
3958 - |
40- ./test/retry.sh "gcloud beta run deploy ${_SERVICE} \
59+ ./test/retry.sh "gcloud run deploy ${_SERVICE} \
4160 --image gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} \
4261 --allow-unauthenticated \
4362 --region ${_REGION} \
44- --platform ${_PLATFORM } \
63+ --service-account ${_SERVICE_ACCOUNT } \
4564 --add-cloudsql-instances ${_CLOUD_SQL_CONNECTION_NAME} \
4665 --update-secrets CLOUD_SQL_CREDENTIALS_SECRET=${_SERVICE}-secrets:latest"
4766
@@ -52,8 +71,13 @@ substitutions:
5271 _SERVICE : idp-sql
5372 _VERSION : manual
5473 _REGION : us-central1
55- _PLATFORM : managed
5674 _CLOUD_SQL_CONNECTION_NAME : $PROJECT_ID:us-central1:idp-sql-instance
5775 _DB_NAME : postgres
5876 _DB_USER : postgres
5977 _DB_PASSWORD : password1234
78+ _SERVICE_ACCOUNT : ${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com
79+
80+ serviceAccount : ' projects/${PROJECT_ID}/serviceAccounts/${_SERVICE_ACCOUNT}'
81+ options :
82+ logging : CLOUD_LOGGING_ONLY
83+ dynamicSubstitutions : true
0 commit comments