0
0
GCPcloud~10 mins

Service accounts for applications 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 service account using gcloud CLI.

GCP
gcloud iam service-accounts create [1] --display-name="My App Service Account"
Drag options to blanks, or click blank then click option'
Amy-app-sa
Bdefault
Cadmin-user
Dcompute-engine
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' which is reserved for default service accounts.
Using names unrelated to the application.
2fill in blank
medium

Complete the code to assign the 'roles/storage.objectViewer' role to the service account.

GCP
gcloud projects add-iam-policy-binding my-project --member="serviceAccount:[1]@my-project.iam.gserviceaccount.com" --role="roles/storage.objectViewer"
Drag options to blanks, or click blank then click option'
Acompute-engine
Bmy-app-sa
Cadmin-user
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' or other service accounts not related to the application.
Incorrect member format.
3fill in blank
hard

Fix the error in the command to activate the service account key file.

GCP
gcloud auth activate-service-account [1] --key-file=key.json
Drag options to blanks, or click blank then click option'
Aadmin-user@my-project.iam.gserviceaccount.com
Bmy-app-sa
Cdefault
Dmy-app-sa@my-project.iam.gserviceaccount.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the service account name without the project domain.
Using unrelated service account emails.
4fill in blank
hard

Fill both blanks to create a JSON key for the service account and save it to a file.

GCP
gcloud iam service-accounts keys create [1] --iam-account=[2]
Drag options to blanks, or click blank then click option'
Akey.json
Bmy-app-sa@my-project.iam.gserviceaccount.com
Cdefault@my-project.iam.gserviceaccount.com
Dcredentials.json
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong file names that don't match the key file.
Using incorrect service account emails.
5fill in blank
hard

Fill all three blanks to set the environment variable for application authentication.

GCP
export GOOGLE_APPLICATION_CREDENTIALS=[1] && gcloud auth activate-service-account [2] --key-file=[3]
Drag options to blanks, or click blank then click option'
Akey.json
Bmy-app-sa@my-project.iam.gserviceaccount.com
Dcredentials.json
Attempts:
3 left
💡 Hint
Common Mistakes
Using different file names for the environment variable and activation.
Using incomplete service account names.