googlecodelabs / feedback

Provide feedback to our codelabs by filing an issue here
18 stars 22 forks source link

[cloud-run-django]: Step 7 | command #2 fails w code 400 #1431

Closed DoctorMG closed 2 months ago

DoctorMG commented 2 months ago

if I replay the codelab and enter the given line gcloud secrets add-iam-policy-binding django_superuser_password \ --member serviceAccount:${SERVICE_ACCOUNT} \ --role roles/secretmanager.secretAccessor

I get as a result gcloud secrets add-iam-policy-binding django_superuser_password --member serviceAccount:${SERVICE_ACCOUNT} --role roles/secretmanager.secretAccessor ERROR: (gcloud.secrets.add-iam-policy-binding) Status code: 400. Invalid service account ()..

Can anybody resolve this?

DoctorMG commented 2 months ago

FYI: whwn I don't use the shell variable SERVICE_ACCOUNT and enter directly the account ID, than I don't get this problem.

glasnt commented 2 months ago

The SERVICE_ACCOUNT is a helper defined in Step 5 so you shouldn't need to hard code the value:

SERVICE_ACCOUNT=$(gcloud iam service-accounts list \
    --filter cloudrun-serviceaccount --format "value(email)")

With any command that uses environment variables, confirm you've set the value by adding a echo to the start of the command to confirm what will be run.