Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Google Cloud Storage bucket using aws-cli

I have an access with both aws and Google Cloud Platform.

Is this possible to do the following,

  1. List Google Cloud Storage bucket using aws-cli
  2. PUT a CSV file to Google Cloud Storage bucket using aws-cli
  3. GET an object(s) from Google Cloud Storage bucket using aws-cli
like image 545
Pez Avatar asked Nov 03 '17 12:11

Pez


People also ask

How do I access Google S3 bucket?

To access external storage, press Cmd/Ctrl E (or click the “+” button below a block), and select the Bucket Access (S3/GCS) option from the Command Bar. You need to select the Provider, and provide the Bucket Name.


1 Answers

It is possible. Per GCP documentation

The Cloud Storage XML API is interoperable with ... services such as Amazon Simple Storage Service (Amazon S3)

To do this you need to enable Interoperability in the Settings screen in the Google Cloud Storage console. From there you can creates a storage access key.

Configure the aws cli with those keys. IE aws configure.

You can then use the aws s3 command with the --endpoint-url flag set to https://storage.googleapis.com.

For example:

MacBook-Pro:~$ aws s3 --endpoint-url https://storage.googleapis.com ls
2018-02-09 14:43:42 foo.appspot.com
2018-02-09 14:43:42 bar.appspot.com
2018-05-02 20:03:08 etc.appspot.com

 aws s3 --endpoint-url https://storage.googleapis.com cp test.md s3://foo.appspot.com
 upload: ./test.md to s3://foo.appspot.com/test.md  
like image 131
user2115867 Avatar answered Sep 28 '22 01:09

user2115867