0
0
GCPcloud~10 mins

Environment variables and secrets in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set an environment variable in a Cloud Run service.

GCP
gcloud run deploy my-service --image gcr.io/my-project/my-image --set-env-vars [1]
Drag options to blanks, or click blank then click option'
A--memory=512Mi
BAPI_KEY=12345
C--region=us-central1
D--allow-unauthenticated
Attempts:
3 left
💡 Hint
Common Mistakes
Using flags unrelated to environment variables like --memory or --region.
Not providing the key=value format.
2fill in blank
medium

Complete the command to access a secret named 'db-password' from Secret Manager in a Cloud Run service.

GCP
gcloud run deploy my-service --image gcr.io/my-project/my-image --set-secrets DB_PASS=[1]
Drag options to blanks, or click blank then click option'
Aprojects/my-project/secrets/db-password/versions/latest
Bdb-password
Cdb-password:latest
Dsecret/db-password
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the secret name without the full path.
Omitting the version part.
3fill in blank
hard

Fix the error in the command to deploy a Cloud Run service with a secret environment variable.

GCP
gcloud run deploy my-service --image gcr.io/my-project/my-image --set-secrets DB_PASS=[1]
Drag options to blanks, or click blank then click option'
Aprojects/my-project/secrets/db-password/versions/latest
Bprojects/my-project/secrets/db-password
Cdb-password
Ddb-password:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out the version in the secret reference.
Using only the secret name without project info.
4fill in blank
hard

Fill both blanks to create a command that sets two environment variables in Cloud Run.

GCP
gcloud run deploy my-service --image gcr.io/my-project/my-image --set-env-vars [1],[2]
Drag options to blanks, or click blank then click option'
AAPI_KEY=abc123
BREGION=us-central1
CMEMORY=512Mi
DTIMEOUT=300
Attempts:
3 left
💡 Hint
Common Mistakes
Using flags unrelated to environment variables.
Not separating variables with commas.
5fill in blank
hard

Fill all three blanks to deploy a Cloud Run service with one environment variable and two secrets.

GCP
gcloud run deploy my-service --image gcr.io/my-project/my-image --set-env-vars [1] --set-secrets DB_PASS=[2],API_KEY=[3]
Drag options to blanks, or click blank then click option'
AENV=production
Bprojects/my-project/secrets/db-password/versions/latest
Cprojects/my-project/secrets/api-key/versions/latest
DENV=dev
Attempts:
3 left
💡 Hint
Common Mistakes
Using incomplete secret references.
Mixing environment variables and secrets in the same flag.