Cross project service account impersonation for service account

We have the use case where project A has some secrets and databases which cannot be moved to another project. We have a project B that uses the secrets and databases from project A.

Project A has a service account X that accesses the secrets and databases.

Project B has a service account Y with no permissions to the secrets and databases. The goal is for service account Y to impersonate X during a build trigger connected to pushes to github. Project B has the cloud build pipeline.

According to this :https://cloud.google.com/build/docs/cloud-build-service-account, section **User-specified service account…**You can create a custom IAM role with an impersonation permission or use pre-defined roles that allow principals to impersonate a service account.

I create a service account X and gave Y permissions to impersonate it (as checked in policy analyser) however when I try to use service account X in project B 's cloud run trigger I get

Failed to update trigger: generic::permission_denied: user does not have impersonation permission on the trigger service account specified: projects/redacted/serviceAccounts/service@project-A.com

  1. What “user” is this referring to? The one using the console? the build service agent?

  2. Is it possible to get a service account Y in B to impersonate service account X in project A during the build process?

According to this https://cloud.google.com/build/docs/securing-builds/configure-user-specified-service-accounts …To use the Triggers page in the Google Cloud console, the user-specified service account and the build trigger must be in the same project.

Is there a workaround for this? Or will cross project account impersonation in cloud build be implemented in the near future?

Thanks in advance.

Hello gridcellcoder,

In regards to your concern, what I can recommend is to have service account X to be able to access Project B. In this way, there is no need for service account Y to impersonate service account X. You can check this third-party documentation on how you can have the service account X to be added in Project B.

Thank you for suggesting this alternative. Is there any plans to support impersonation in the future? Is this not more secure as the impersonation takes place using a temporary token?