3

I've been dealing with cross-projects service accounts recently, but I'm unable to figure out how billing works exactly, as I have no visibility on it due to org policies.

Let's say I have a project A, where I create service account X. I then add this service account to project B, where my data is stored in BigQuery, with proper roles.

If service account X is used to read 100GB of data everyday from BigQuery in project B, who gets billed for the operation? Project A or B, and/or how would you suggest to test this? I hoped to find the answer in the job response object, but it doesn't seem to be there.

It would make sense to be project A, as that service account X is a "guest" in project B with read access to the data it needs, but I don't know how to test it.

Thank you!

FoxHounder
  • 51
  • 1
  • 5
  • 3
    https://stackoverflow.com/a/53952885/8016720 – John Hanley Mar 12 '22 at 05:17
  • The comment of @JohnHanley is perfect. The cost depends on which project the job run, doesn't matter "who" run the job. – guillaume blaquiere Mar 12 '22 at 12:21
  • Thank you @JohnHanley and Guillaume. I had read that, but if I'm using the bq command from nodejs for example, I can specify the param "--project_id" which the doc says "specifies the project to use for commands". I tested it, and I can run the same query by specifying both project_id=A and B with no errors. so I was wondering: unless I'm mistaken completely, if Service Account X sets the project_id to Project B, does the billing also shifts to B? Is there any way I can prevent this? – FoxHounder Mar 13 '22 at 13:25
  • Quick update: if I don't give bigquery.jobs.create role in Project A, the service account will not be able to query Project B, regardless of the project_id parameter. It doesn't matter if it has bigquery.jobs.create in project B. It seems to indicate that project A is the one billed, always, as the job created is in A. – FoxHounder Mar 13 '22 at 14:47

0 Answers0