Repository navigation
Expand file tree
/
Copy pathgoogle-cloud-storage.Rmd
More file actions
115 lines (82 loc) · 5.45 KB
/
Copy pathgoogle-cloud-storage.Rmd
File metadata and controls
115 lines (82 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
title: "Google Cloud Storage (GCS) Setup Guide"
subtitle: "A step-by-step guide for creating and configuring Google Cloud Storage buckets."
fontsize: 12pt
output:
html_document:
df_print: paged
toc: yes
toc_depth: 2
highlight: pygments
includes:
in_header: GA_Script.html
after_body: comment.html
# pdf_document:
# toc: yes
# toc_depth: 3
# word_document:
# toc: yes
# toc_depth: '3'
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \renewcommand{\footrulewidth}{0.4pt}
- \fancyhead[LE,RO]{\thepage}
- \geometry{left=1in,top=0.75in,bottom=0.75in}
- \fancyfoot[CE,CO]{{\includegraphics[height=0.5cm]{images/cc-by-nc.png}} Ujaval Gandhi http://www.spatialthoughts.com}
classoption: a4paper
---
Google Cloud Storage is a data storage service that allows you to store binary and unstructured data. It is a cheap and fast option to store geospatial data in cloud-optimized formats such as Cloud Optimized GeoTIFFs (COGs), Zarr archives and GeoParquet files. This guide will show you how to use this service to activate the service, create a bucket, configure it for public access and upload your data.
> This is a simplified guide for our course participants and not an official document. Refer to the [Google Cloud Storage Documentation](https://docs.cloud.google.com/storage/docs){target="_blank"} for official instructions.
----
## Before You Start
To use the Google Cloud Storage service, you must have a Google Cloud Project with billing enabled. See our [Google Cloud Sign-up Guide](google-cloud-sign-up.html){target="_blank"} to learn how to setup a project and enable billing.
## Create a Bucket
A **Bucket** is the top-level container in Google Cloud Storage. It is like a *folder* that can contain other folders and files. Let's create a bucket.
1. Open your [Google Cloud Console](https://console.cloud.google.com/){target="_blank"}. Open the menu from the left-hand panel and go to the **Cloud Storage → Overview**.
```{r echo=FALSE, fig.align='center', out.width='75%'}
knitr::include_graphics('images/google_cloud_storage/bucket1.png')
```
2. Click the *+ Create bucket* button.
```{r echo=FALSE, fig.align='center', out.width='75%'}
knitr::include_graphics('images/google_cloud_storage/bucket2.png')
```
3. Enter a bucket name. The bucket name has to be globally-unique as you can refer to your bucket with just it's name like `gs://<my-bucket-name>` without referring to a project or an account name. Once you find a unique name for your bucket, click *Continue*.
```{r echo=FALSE, fig.align='center', out.width='50%'}
knitr::include_graphics('images/google_cloud_storage/bucket3.png')
```
4. Next, choose a region for your data. The data will be stored in a data center in the chosen region. You should choose a region closest to the users who will access the data. Click *Continue*.
```{r echo=FALSE, fig.align='center', out.width='50%'}
knitr::include_graphics('images/google_cloud_storage/bucket4.png')
```
5. Next, you need to decide the storage class. For data that will be accessed in your web applications and GIS viewers, the *Standard** storage class is a good choice. Click *Continue*.
```{r echo=FALSE, fig.align='center', out.width='50%'}
knitr::include_graphics('images/google_cloud_storage/bucket5.png')
```
6. If you are create a bucket for public access (i.e. hosting data for a website), uncheck the *Enforce public access prevention on this bucket* option. You can review the defaults for *Choose how to protect object data* and Click *Create*.
```{r echo=FALSE, fig.align='center', out.width='50%'}
knitr::include_graphics('images/google_cloud_storage/bucket6.png')
```
7. Your bucket is now created.
```{r echo=FALSE, fig.align='center', out.width='75%'}
knitr::include_graphics('images/google_cloud_storage/bucket7.png')
```
## Setup a CORS configuration
Cross-Origin Resource Sharing (CORS) is a browser security mechanism that allows servers to allow or block reading of data from a different domain. If you plan to access the data from your cloud storage bucket via any browser-based application (i.e. GeoLibre), you must setup a CORS configuration. Without it, browsers block cross-domain requests due to the same-origin policy.
1. Click your bucket name and select the *Configuration* tab. Locate the *Cross-origin resource sharing* option and click *Edit*.
```{r echo=FALSE, fig.align='center', out.width='75%'}
knitr::include_graphics('images/google_cloud_storage/cors1.png')
```
2. In the *Edit Cross-Origin Resource Sharing configuration* dialog, check the *Allow cross-origin resource sharing* box and click *Add a configuration*.
```{r echo=FALSE, fig.align='center', out.width='50%'}
knitr::include_graphics('images/google_cloud_storage/cors2.png')
```
3. Enter **`*`** as the *List of allowed origins* and check the **Head** and **Get** methods. `*` indicates that any website or app can request data from this bucket. If you plan to use the data in a specific web-app, you should enter that URL instead. *Head* allows readers to fetch metadata (used by cloud-native files) and *Get* method allows fetching the data from the file. Click *Save*.
```{r echo=FALSE, fig.align='center', out.width='50%'}
knitr::include_graphics('images/google_cloud_storage/cors3.png')
```
4. The CORS configuration is now complete. You can now upload data to your bucket which can be read by any app or website.
```{r echo=FALSE, fig.align='center', out.width='75%'}
knitr::include_graphics('images/google_cloud_storage/cors4.png')
```
----