-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathinit_common.sh
executable file
·30 lines (22 loc) · 951 Bytes
/
init_common.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
#!/usr/bin/env bash
set -eo pipefail
yc init
NETWORK_ID=$(yc vpc network create --name yc-auto-network --format json | jq -r .id)
zones=(a b c)
for i in ${!zones[@]}; do
echo "Creating subnet yc-auto-subnet-$i"
yc vpc subnet create --name yc-auto-subnet-$i \
--zone ru-central1-${zones[$i]} \
--range 192.168.$i.0/24 \
--network-id ${NETWORK_ID}
done
FOLDER_ID=$(yc config get folder-id)
FOLDER_NAME=$(yc resource-manager folder get ${FOLDER_ID} --format json | jq -r .name)
SERVICE_ACCOUNT_ID=$(yc iam service-account create --name ${FOLDER_NAME} --format json | jq -r .id)
yc resource-manager folder add-access-binding --role editor --subject serviceAccount:${SERVICE_ACCOUNT_ID} ${FOLDER_ID}
render_template() {
echo "Rendering " $1
sed -i '' -e 's/${NETWORK_ID}/'${NETWORK_ID}'/g' -e 's/${SERVICE_ACCOUNT_ID}/'${SERVICE_ACCOUNT_ID}'/g' $1
}
render_template 02/CLI/specification.yaml
render_template 03/specification.yaml