Reputation: 1426
I am trying to use the "create with container" method but getting the following error :
ERROR: (gcloud.compute.instances.create-with-container) Could not fetch resource: Step #2: - Required 'compute.instances.create' permission for 'projects/local_test_prod1283/zones/us-central1-a/instances/instanceapptraining'
I checked and the project local_test_prod1283 does have role compute.instanceAdmin.v1
My cloud buil yaml below :
steps:
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/local_test_prod1283/apptraining', '.']
- name: 'gcr.io/cloud-builders/docker'
args: ["push", "gcr.io/local_test_prod1283/apptraining"]
- name: 'gcr.io/cloud-builders/gcloud'
args: ['compute', 'instances', 'create-with-container', 'instanceapptraining', '--machine-type=n1-standard-1', '--zone=us-central1-a', '--preemptible', '--container-image=gcr.io/local_test_prod1283/apptraining']
What am I missing here ?
Upvotes: 2
Views: 1307
Reputation: 5015
Use Cloud Shell:
gcloud projects add-iam-policy-binding $PROJECT --role roles/compute.instances.create --member='serviceAccount:test-proj1@@cloudbuild.gserviceaccount.com'
Upvotes: 1
Reputation: 1426
Nevermind, i had to add the compute.instanceAdmin.v1 to the @cloudbuild.gserviceaccount.com.
Upvotes: 3