Manoj Pandey
Manoj Pandey

Reputation: 21

Error Uploading CSV to Google Cloud Storage through Cloud SQL API

I have some data in Google Cloud SQL, which I am trying to transfer to Google Cloud Storage using Cloud SQL API(beta) (export) function. For this, I have installed jupyter notebook on google compute engine and I am running the python code (to connect to cloud sql API and export the date to cloud storage in a csv file) on that.

The python code does not throw any error and also there is no error body in API response. However, the API's response says "u'status': u'PENDING'" and I see the following error (in logs of Cloud SQL Dashboard) : error uploading CSV file to GCS: gs://[BUCKET_NAME]/[FILE_NAME].csv: Access denied for account [SERVICE_ACCOUNT_NAME]@speckle-umbrella-11.iam.gserviceaccount.com (permission issue?)

How do I ensure I have all the relevant access for the account ([SERVICE_ACCOUNT_NAME]@speckle-umbrella-11.iam.gserviceaccount.com) ? I am unable to locate this account or give myself access to this .

Upvotes: 2

Views: 915

Answers (2)

Vadim
Vadim

Reputation: 5126

You need to grant the Cloud SQL instance service account access to your bucket. Visit the export documentation and click the GCLOUD (2ND GEN) tab which will show you the commands you need to use.

The command to grant the service account access to the bucket is

gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:W gs://[BUCKET_NAME]

Upvotes: 1

Pol Arroyo
Pol Arroyo

Reputation: 485

By default Google Compute Engine instances have read only scope for Google Cloud Storage.

You should confirm that the Google Compute Engine instance scope is set to read/write.

Upvotes: 1

Related Questions