Fabinout
Fabinout

Reputation: 878

Setting up service accounts between two projects

I have two GCP projects, one for continuous integration builds, and one for the team project.

com-build : contains

service account : [email protected] with roles service-account-administrator and cloudbuild-service-account

g iam service-accounts get-iam-policy [email protected] --project=com-build

--> etag: ACAB

com-project: contains

service account : [email protected] with roles service-account-administrator and compute-instance-administrator

g iam service-accounts get-iam-policy [email protected] --project=com-project

--> etag: ACAB –

I setup the cloudbuild.json file to update its container on code push, like this :

{
  "steps": [
    {
      "name": "gcr.io/cloud-builders/docker",
      "args": [
        "build",
        "-t",
        "****:latest",
        "."
      ]
    },
    {
      "name": "gcr.io/cloud-builders/docker",
      "args": [
        "push",
        "***:latest"
      ]
    },
    {
      "name": "gcr.io/cloud-builders/gcloud",
      "args": [
        "compute",
        "instances",
        "update-container",
        "***",
        "--project=com-project",
        "--zone=somewhere"
      ]
    }
  ]
}

I get the following error :

ERROR: (gcloud.compute.instances.update-container) The user does not have access to service account '[email protected]'. User: '[email protected]'. Ask a project owner to grant you the iam.serviceAccountUser role on the service account

But both service-accounts have the role (I checked 20 times on iam settings) am I missing something ?

Upvotes: 0

Views: 645

Answers (1)

Fabinout
Fabinout

Reputation: 878

Found my problem :
[email protected] had to have access to Editor's role, in order to edit ressources in the other project

rights must be Editor and service account admin

Upvotes: 0

Related Questions