piotrekw
piotrekw

Reputation: 237

Accessing files in the Google Cloud Storage from two different google cloud projects

Consider the following situation:

Now, here is what I want to achieve: I want application A to create files inside the bucket and then application B to read them.

At first I tried to simply create a file with cloudstorage.open(file_name, 'w') and then read its status with cloudstorage.stat(file_name, 'r'), but this way I end up with the following error while reading:

ForbiddenError at /.../
Expect status [200] from Google Storage. But got status 403.

(The error message provides also request/response information: path, headers, body and extra info. Please let me know if you think they may be helpful in solving this case)

Then I started experimenting with ACLs by setting the x-googl-acl option while creating a file, for example:

cloudstorage.open(file_name, 'w', options={'x-goog-acl': 'authenticated-read'})

Although ACLs work as intended, none of the available options seem to fit my requirements:

It looks like I ran out of options, but I can't believe that such a simple thing cannot be achieved with the Cloud Storage. The only solution that comes to my mind is changing system's architecture, but I would like to avoid it. Any other suggestions?

Upvotes: 6

Views: 1860

Answers (1)

Ashish Awasthi
Ashish Awasthi

Reputation: 1327

Add the accessor Service Accounts (e.g. [email protected] or [email protected] for compute engine) as member with 'Editor' permission on project with the GCS bucket to use. This can be done in IAM page of the project that owns the bucket: https://console.developers.google.com/iam-admin/iam/project?project=app1

Upvotes: 6

Related Questions