Reputation: 2130
So I have a command like this that should create the instance template and give it the "cloud-platform" scope (which should give full access according to docs):
gcloud compute instance-templates create "webserver-template"\
--source-instance=webserver --source-instance-zone=us-east4-c\
--configure-disk=instantiate-from=custom-image,custom-image=projects/myproject-dev/global/images/webserver-image,device-name=webserver\
--network=vpc-dev --scopes=cloud-platform
However, GCP seems to ignore that scope and assigns the default ones instead. Am I missing something here? I did go to an instance template in the GCP UI and created a new one based on it, and specified the option to "Allow full access to all Cloud APIs". When I then use gcloud to describe that template, the scope is "cloud-platform" as it should be. I just can't figure out how to do it all in one gcloud command.
EDIT: I also tried "--scopes=https://www.googleapis.com/auth/cloud-platform"
Upvotes: 1
Views: 526
Reputation: 2130
I figured out what was going on. As you can see in my original question, I'm specifying the flag "--source-instance". And according to the docs:
The name of the source instance that the instance template will be created from. You can override machine type and labels. Values of other flags will be ignored and values from the source instance will be used instead.
So the scopes flag was rightfully being ignored, and my source instance had the more limited scopes assigned to it.
Upvotes: 2
Reputation: 81336
The problem is the scopes command-line option. Change to
--scopes=https://www.googleapis.com/auth/cloud-platform
Upvotes: 1