Reputation: 4797
I have two projects. I store data in project_A
and build tables in project_B
. I have created a service_account.json
for both of them, but I don't know how to use both files at the same time when I need to load the data from project_A
and build the tables in project_B
.
The data is stored in URI:
gs://project_A//*
The table will live in project_B
table name huge_table
from google import storage, bigquery
proj_a_client = storage.Client.from_service_account_json(service_acct_A.json)
proj_b_client = bigquery.Client.from_service_account_json(service_acct_B.json)
dest_table = proj_b_client.dataset('DS_B').table('huge_table')
uri = 'gs://project_A//*'
job_config = bigquery.LoadJobConfig()
load_job = proj_b_client.load_table_from_uri(uri,
dest_table,
job_config=job_config)
But I get the error:
google.api_core.exceptions.Forbidden: 403 Access Denied: File gs://project_A/: Access Denied
Upvotes: 1
Views: 1251
Reputation: 1544
You have to make sure service_acct_B
has storage access to project_A
:
In project_A
,
IAM & admin
service_acct_B
with (at a minimum) Storage Object Viewer
roleAs a matter of fact, you don't use/need a service_acct_A
here so
proj_a_client = storage.Client.from_service_account_json(service_acct_A.json)
is redundant.
Upvotes: 1