问题
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