The service account integrated with Bitbucket is unable to list
projects:
gcloud projects list
#=>
Listed 0 items.
or set
$MY_PROJECT
:
gcloud config set project $MY_PROJECT
#=>
Updated property [core/project].
because the output above is immediately followed by this warning:
WARNING: You do not appear to have access to project [$MY_PROJECT] or it does not exist
The warning above contradicts the output of the following:
gcloud config list --format="value(core.project)"
#=>
$MY_PROJECT
Are there any missing steps or prerequisites in order to properly authorize this service account to list
and set
$MY_PROJECT
?
My bitbucket-pipelines.yaml
file:
name: Test google auth
image: google/cloud-sdk:latest
script:
- echo $KEY_FILE | base64 --decode --ignore-garbage > ~/google-key.json
- gcloud auth activate-service-account --key-file ~/google-key.json
- gcloud projects list
- gcloud config set project $MY_PROJECT
- gcloud container clusters get-credentials $MY_CLUSTER --region $REGION
services:
- docker
If you successfully activate the service account as follows:
gcloud auth activate-service-account --key-file service-account-key.json
and you can see it as the ACTIVE one after executing the following:
gcloud auth list
and still, get ZERO items
Listed 0 items.
after executing the following:
gcloud projects list
THEN
Make sure to add your service account as a member to your Organization beside the project and assign it a Viewer role.