0
0
GCPcloud~10 mins

Secret Manager for credentials 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 create a new secret in Google Cloud Secret Manager.

GCP
gcloud secrets create [1] --replication-policy="automatic"
Drag options to blanks, or click blank then click option'
Amy-secret
Bsecret-manager
Ccredentials
Dproject-id
Attempts:
3 left
💡 Hint
Common Mistakes
Using project ID instead of secret name
Including spaces in the secret name
Omitting the replication policy
2fill in blank
medium

Complete the code to add a new version of the secret with the content from a file.

GCP
gcloud secrets versions add [1] --data-file=credentials.json
Drag options to blanks, or click blank then click option'
Aproject-id
Bcredentials
Csecret-version
Dmy-secret
Attempts:
3 left
💡 Hint
Common Mistakes
Using the file name instead of the secret name
Using project ID instead of secret name
3fill in blank
hard

Fix the error in the command to access the latest secret version.

GCP
gcloud secrets versions access [1] --secret=my-secret
Drag options to blanks, or click blank then click option'
Alatest
Bcurrent
C1
Dnewest
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent version keyword
Using a version number that does not exist
4fill in blank
hard

Fill both blanks to grant the Secret Manager Accessor role to a service account.

GCP
gcloud projects add-iam-policy-binding [1] --member='serviceAccount:[2]' --role='roles/secretmanager.secretAccessor'
Drag options to blanks, or click blank then click option'
Amy-project-id
Buser@example.com
Cmy-service-account@my-project-id.iam.gserviceaccount.com
Dsecret-accessor
Attempts:
3 left
💡 Hint
Common Mistakes
Using a user email instead of a service account email
Using an incorrect project ID
5fill in blank
hard

Fill all three blanks to retrieve the secret value in a Python script using the Secret Manager client.

GCP
from google.cloud import secretmanager

client = secretmanager.SecretManagerServiceClient()
name = client.secret_version_path([1], [2], [3])
response = client.access_secret_version(name=name)
secret = response.payload.data.decode('UTF-8')
Drag options to blanks, or click blank then click option'
A"my-project-id"
B"my-secret"
C"latest"
D"secret-version"
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without quotes
Using incorrect version string
Swapping the order of arguments