Skip to content

Commit dd3984c

Browse files
committed
Add docs about required permissions
1 parent 619fd98 commit dd3984c

File tree

2 files changed

+72
-7
lines changed

2 files changed

+72
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.npmrc
2+
Makefile
23
build/
34
dist/
45
docs/
5-
Makefile
6+
key.json
67
node_modules/

README.md

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,68 @@ entrypoint: fileset serve
5656
gcloud app deploy app.yaml
5757
```
5858

59+
### Authentication for deployment
60+
61+
Before you are able to deploy your files, you'll need to set up authentication
62+
to deploy.
63+
64+
1. Identify the service account to use.
65+
66+
Authentication to upload your files is done using a service account. You'll
67+
generally want to use one of two service accounts:
68+
69+
a. When the command is invoked from Google Cloud Build, your project's Cloud
70+
Build service account (`<ProjectNumber>@cloudbuild.gserviceaccount.com`) is
71+
used.
72+
73+
To determine your project's project number:
74+
75+
```bash
76+
gcloud projects describe <AppID>
77+
```
78+
79+
b. When the command is invoked locally (i.e. for testing or for manual uploads),
80+
you'll likely want to use your App Engine app's default service account
81+
(`<AppID>@appspot.gserviceaccount.com`). You can download a service account key
82+
by running:
83+
84+
```bash
85+
gcloud iam service-accounts keys create \
86+
key.json \
87+
--iam-account <AppID>@appspot.gserviceaccount.com
88+
```
89+
90+
NOTE: This will download a `key.json` to your current directory. Avoid
91+
committing this to your Git repository. You'll want to add `key.json` to
92+
`.gitignore`.
93+
94+
2. Ensure service account has permissions.
95+
96+
The following permissions are needed:
97+
98+
- Cloud Datastore (manifests are stored here): Cloud Datastore Owner
99+
(`datastore.owner`)
100+
- Cloud Storage (files are uploaded here): Storage Object Admin
101+
(`storage.objectAdmin`)
102+
103+
If using the App Engine default service account, you will not need to modify the
104+
permissions, as the service account has the "Project Editor" permission by
105+
default.
106+
107+
If using the Cloud Build service account (or any other service account), you'll
108+
need to add the above two permissions to the account. That can be done via the
109+
IAM page (`https://console.cloud.google.com/access/iam?project=<AppId>`) or via
110+
the `gcloud` CLI:
111+
112+
```
113+
for role in datastore.owner storage.objectAdmin g; do \
114+
gcloud projects add-iam-policy-binding \
115+
<AppId>
116+
--member=serviceAccount:<ProjectNumber>@cloudbuild.gserviceaccount.com \
117+
--role=roles/$role \
118+
; done
119+
```
120+
59121
### Deployment setup
60122

61123
1. Create a `fileset.yaml` configuration file.
@@ -66,17 +128,19 @@ schedule:
66128
default: master # Specify a branch for the prod deployment.
67129
```
68130
69-
2. Generate your files. Use a static site generator or just manually create a
70-
directory containing files to upload. In the below example, the files in the
71-
directory `build` are uploaded.
131+
2. Generate your files.
132+
133+
Use a static site generator or just manually create a directory containing files
134+
to upload. In the below example, the files in the directory `build` are
135+
uploaded.
72136

73-
3. Upload your files.
137+
4. Upload your files.
74138

75139
```bash
76140
fileset upload -s siteId build
77141
```
78142

79-
4. That's it! Files have been uploaded to Google Cloud Storage and the uploaded
143+
5. That's it! Files have been uploaded to Google Cloud Storage and the uploaded
80144
directory is now being served by the application server.
81145

82146
TODO: Document Identity-Aware Proxy setup and CLI authentication.
@@ -110,4 +174,4 @@ Staging URL: https://default-f3a9abb-dot-fileset-dot-appid.appspot.com
110174
(staging) $ fileset upload build
111175
...
112176
Staging URL: https://default-4fb48ce-dot-fileset-dot-appid.appspot.com
113-
```
177+
```

0 commit comments

Comments
 (0)