2019-05-14 17:16:34 +08:00
|
|
|
# sa-gen
|
|
|
|
|
2019-05-16 20:37:38 +08:00
|
|
|
Create up to 100 service accounts for a google project using gcloud SDK
|
|
|
|
|
|
|
|
_forked from DashLt at https://gist.github.com/DashLt/4c6ff6e9bde4e9bc4a9ed7066c4efba4_ and
|
|
|
|
|
|
|
|
_forked from mc2squared at https://gist.github.com/mc2squared/01c933a8172a26af88285610a0e5af8d_
|
|
|
|
|
|
|
|
|
2019-05-24 06:39:19 +08:00
|
|
|
**requires gcloud command line tools**
|
2019-05-27 11:14:25 +08:00
|
|
|
install with ```curl https://sdk.cloud.google.com | bash```
|
|
|
|
or go to ```https://cloud.google.com/sdk/docs/quickstarts``` to read more and install in non-linux OSes.
|
2019-05-16 20:37:38 +08:00
|
|
|
|
|
|
|
max 100 service accounts per project
|
|
|
|
|
2019-06-02 12:50:18 +08:00
|
|
|
max 12 projects for a normal gmail account.
|
|
|
|
max 50 projects for a paid gsuite account. You can request more project from Google if necessary.
|
2019-05-16 20:37:38 +08:00
|
|
|
|
2019-06-02 12:56:36 +08:00
|
|
|
run `gcloud init --console-only` first and select a project for your first batch of 100.
|
2019-06-02 14:29:27 +08:00
|
|
|
For subsequent batches of 100 you run `gcloud init` again, pick 1, then 2 to select then next project.
|
2019-06-02 12:50:18 +08:00
|
|
|
|
|
|
|
Before running the script:
|
2019-05-16 20:37:38 +08:00
|
|
|
Create a folder for your keys before running the script
|
|
|
|
|
2019-06-02 12:57:03 +08:00
|
|
|
Set your key directory, default is `KEYS_DIR=/opt/sa`. There is no need to change your KEYS_DIR as you
|
2019-06-02 12:51:50 +08:00
|
|
|
run more batches and projects, as long as you increment the key numbers appropriately to not overwrite existing keys.
|
2019-05-16 20:37:38 +08:00
|
|
|
|
|
|
|
If you want to create more than 100 jsons then increment COUNT for each batch.
|
2019-06-02 12:50:18 +08:00
|
|
|
For the first batch set COUNT=1 and sagen{1..100} in the script.
|
|
|
|
|
2019-06-02 12:56:36 +08:00
|
|
|
For more batches edit and change `COUNT=101` and `sagen{101..200}` in the script. Third batch `COUNT=201` `sagen{201..300}` and so on...
|
2019-06-02 12:51:50 +08:00
|
|
|
|
|
|
|
|