-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-projects.sh
executable file
·42 lines (32 loc) · 1.13 KB
/
create-projects.sh
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
#!/usr/bin/env bash
# shellcheck disable=SC1091
# when a command fails, bash exits instead of continuing with the rest of the script
set -o errexit
# make the script fail, when accessing an unset variable
set -o nounset
# pipeline command is treated as failed, even if one command in the pipeline fails
set -o pipefail
# enable debug mode, by running your script as TRACE=1
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
source "$(dirname "$0")/common.sh"
source "$(dirname "$0")/projects.sh"
function main() {
for project in "${PROJECTS[@]}"; do
create_project "$project" "$BILLING_ACCOUNT"
done
}
function create_project () {
local projectId="${1}-${POSTFIX}"
local billingAccount="$2"
echo "Creating project $projectId"
create_project "$projectId"
enable_billing "$projectId" "$billingAccount"
echo "Finished with project $projectId"
}
function enable_billing() {
local projectId="$1"
local billingAccount="$2"
echo "Enabling billing account $billingAccount for project $projectId"
gcloud beta billing projects link "${projectId}" --billing-account="${billingAccount}"
}
main "$@"