ERROR: (gcloud.services.enable) User does not have permission to access project (or it may not exist): The caller does not have permission

只谈情不闲聊 提交于 2019-12-23 21:27:06

问题


I'm looking to put together a script that I can run from Cloud Shell to enable an API in all projects. It is successfully going through each project, but I am getting a permission denied message for every one. I am the owner so there shouldn't be any permission issues.

As a permission test, if I run just "gcloud services enable cloudresourcemanager.googleapis.com", the API successfully enables.

What am I missing?

#!/bin/bash
for project in  $(gcloud projects list --format="value(projectId)")
do
    echo "ProjectId:  $project"
    for enableapi in $(gcloud services enable cloudresourcemanager.googleapis.com list --project $project --format=list)
     do
        echo "    -> Enabled $enableapi"
    done
done

回答1:


Lucas, this way could work:

#!/bin/bash
for project in  $(gcloud projects list --format="value(projectId)")
do
    echo "ProjectId:  $project"
    gcloud config set project $project
    gcloud services enable cloudresourcemanager.googleapis.com  --project $project
done

I'm following this doc.



来源:https://stackoverflow.com/questions/54757388/error-gcloud-services-enable-user-does-not-have-permission-to-access-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!