@@ -27,8 +27,14 @@ the name of the project you want to use.
2727
2828## Enable the Services
2929
30+ Set the active project:
31+
32+ ``` sh
33+ gcloud config set project ${GOOGLE_CLOUD_PROJECT}
34+ ```
35+
3036``` sh
31- gcloud services enable --project= " ${GOOGLE_CLOUD_PROJECT} " \
37+ gcloud services enable \
3238 bigtable.googleapis.com \
3339 cloudbuild.googleapis.com \
3440 cloudfunctions.googleapis.com \
@@ -44,10 +50,8 @@ gcloud services enable --project="${GOOGLE_CLOUD_PROJECT}" \
4450## Create Pub/Sub Topics
4551
4652``` sh
47- gcloud pubsub topics create testing \
48- --project=" ${GOOGLE_CLOUD_PROJECT} "
49- gcloud pubsub topics create gcs-changes \
50- --project=" ${GOOGLE_CLOUD_PROJECT} "
53+ gcloud pubsub topics create testing
54+ gcloud pubsub topics create gcs-changes
5155```
5256
5357## Create a Bucket
@@ -77,7 +81,6 @@ Add this service account to the topic:Grant the
7781
7882``` shell
7983gcloud pubsub topics add-iam-policy-binding \
80- --project=" ${GOOGLE_CLOUD_PROJECT} " \
8184 --role=" roles/pubsub.publisher" \
8285 --member=" serviceAccount:${GCS_SA} " \
8386 gcs-changes
@@ -98,7 +101,6 @@ readonly SA_ID="eventarc-trigger-sa"
98101readonly SA_NAME=" ${SA_ID} @${GOOGLE_CLOUD_PROJECT} .iam.gserviceaccount.com"
99102
100103gcloud iam service-accounts create " ${SA_ID} " \
101- " --project=${GOOGLE_CLOUD_PROJECT} " \
102104 --description=" Event Arg Triggers"
103105```
104106
@@ -158,7 +160,6 @@ Create a Cloud Run deployment running the hello world example:
158160
159161``` sh
160162gcloud run deploy gcf-hello-world-http \
161- --project=" ${GOOGLE_CLOUD_PROJECT} " \
162163 --image=" gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-hello-world-http:latest" \
163164 --region=" us-central1" \
164165 --platform=" managed" \
@@ -169,7 +170,6 @@ Test it by sending a request with `curl(1)`:
169170
170171``` sh
171172HTTP_SERVICE_URL=$( gcloud run services describe \
172- --project=" ${GOOGLE_CLOUD_PROJECT} " \
173173 --platform=" managed" \
174174 --region=" us-central1" \
175175 --format=" value(status.url)" \
@@ -185,7 +185,6 @@ triggers:
185185
186186``` sh
187187gcloud run deploy gcf-hello-world-pubsub \
188- --project=" ${GOOGLE_CLOUD_PROJECT} " \
189188 --image=" gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-hello-world-pubsub:latest" \
190189 --region=" us-central1" \
191190 --platform=" managed" \
@@ -199,7 +198,6 @@ PROJECT_NUMBER="$(gcloud projects list \
199198 --filter=" PROJECT_ID=${GOOGLE_CLOUD_PROJECT} " \
200199 --format=" value(project_number)" ) "
201200gcloud beta eventarc triggers create gcf-hello-world-pubsub-trigger \
202- --project=" ${GOOGLE_CLOUD_PROJECT} " \
203201 --location=" us-central1" \
204202 --destination-run-service=" gcf-hello-world-pubsub" \
205203 --destination-run-region=" us-central1" \
@@ -210,7 +208,6 @@ Test by sending a message to the right topic:
210208
211209``` sh
212210TOPIC=$( gcloud beta eventarc triggers describe gcf-hello-world-pubsub-trigger \
213- --project=" ${GOOGLE_CLOUD_PROJECT} " \
214211 --location=" us-central1" \
215212 --format=" value(transport.pubsub.topic)" )
216213NONCE=$( date +%s) -${RANDOM}
@@ -221,7 +218,6 @@ And then verify this message shows up in the log:
221218
222219``` sh
223220gcloud logging read \
224- --project=" ${GOOGLE_CLOUD_PROJECT} " \
225221 --format=" value(textPayload)" \
226222 " resource.type=cloud_run_revision AND resource.labels.service_name=gcf-hello-world-pubsub AND logName:stdout"
227223```
@@ -233,7 +229,6 @@ triggers:
233229
234230``` sh
235231gcloud run deploy gcf-hello-world-storage \
236- --project=" ${GOOGLE_CLOUD_PROJECT} " \
237232 --image=" gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-hello-world-storage:latest" \
238233 --region=" us-central1" \
239234 --platform=" managed" \
@@ -244,7 +239,6 @@ Create a trigger for Cloud Storage events:
244239
245240``` sh
246241gcloud beta eventarc triggers create gcf-hello-world-storage-trigger \
247- --project=" ${GOOGLE_CLOUD_PROJECT} " \
248242 --location=" us-central1" \
249243 --destination-run-service=" gcf-hello-world-storage" \
250244 --destination-run-region=" us-central1" \
@@ -257,7 +251,6 @@ And then verify this message shows up in the log:
257251
258252``` sh
259253gcloud logging read \
260- --project=" ${GOOGLE_CLOUD_PROJECT} " \
261254 --format=" value(textPayload)" \
262255 " resource.type=cloud_run_revision AND resource.labels.service_name=gcf-hello-world-storage AND logName:stdout"
263256```
@@ -268,7 +261,6 @@ Finally verify this works by running the Cloud Build:
268261
269262``` sh
270263gcloud builds submit \
271- " --project=${GOOGLE_CLOUD_PROJECT} " \
272264 " --substitutions=SHORT_SHA=$( git rev-parse --short HEAD) " \
273265 " --config=ci/build-examples.yaml"
274266```
@@ -314,13 +306,11 @@ pack build -v \
314306 " gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-tutorial-cloud-bigtable"
315307docker push " gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-tutorial-cloud-bigtable"
316308gcloud run deploy gcf-tutorial-cloud-bigtable \
317- --project=" ${GOOGLE_CLOUD_PROJECT} " \
318309 --image=" gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-tutorial-cloud-bigtable:latest" \
319310 --region=" us-central1" \
320311 --platform=" managed" \
321312 --allow-unauthenticated
322313BIGTABLE_SERVICE_URL=$( gcloud run services describe \
323- --project=" ${GOOGLE_CLOUD_PROJECT} " \
324314 --platform=" managed" \
325315 --region=" us-central1" \
326316 --format=" value(status.url)" \
@@ -333,7 +323,7 @@ curl -H "projectID: ${GOOGLE_CLOUD_PROJECT}" -H "instanceID: test-instance-0" -H
333323Create the instance:
334324
335325``` shell
336- gcloud --project= " ${GOOGLE_CLOUD_PROJECT} " spanner instances create test-instance-0 \
326+ gcloud spanner instances create test-instance-0 \
337327 --config=" regional-us-central1" \
338328 --description=" Test instance for CI builds" \
339329 --nodes=1
@@ -358,14 +348,12 @@ pack build -v \
358348 " gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-tutorial-cloud-spanner"
359349docker push " gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-tutorial-cloud-spanner"
360350gcloud run deploy gcf-tutorial-cloud-spanner \
361- --project=" ${GOOGLE_CLOUD_PROJECT} " \
362351 --image=" gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-tutorial-cloud-spanner:latest" \
363352 --region=" us-central1" \
364353 --platform=" managed" \
365354 --set-env-vars=GOOGLE_CLOUD_PROJECT=" ${GOOGLE_CLOUD_PROJECT} " ,SPANNER_INSTANCE=test-instance-0,SPANNER_DATABASE=test-db \
366355 --allow-unauthenticated
367356SPANNER_SERVICE_URL=$( gcloud run services describe \
368- --project=" ${GOOGLE_CLOUD_PROJECT} " \
369357 --platform=" managed" \
370358 --region=" us-central1" \
371359 --format=" value(status.url)" \
0 commit comments