/create.sh

raw link view readme
1
2 if [ -z "$1" ]; then
3 echo "usage: create.sh type resource_group"
4 exit 1
5 fi
6
7 if [ -z "$2" ]; then
8 echo "usage: create.sh type resource_group"
9 exit 1
10 fi
11
12 if [ ! -z "$3" ]; then
13 SSH_KEY_PATH=~/.ssh/id_rsa.pub
14 echo testing for $SSH_KEY_PATH
15 if [ -f "$SSH_KEY_PATH" ]; then
16 SSH_KEY=`cat "$SSH_KEY_PATH"`
17 USERNAME=$3
18 fi
19 fi
20
21 TYPE=$1
22 RESOURCE_GROUP=$2
23
24 if [ -z "$SSH_KEY" ] ; then
25 if [ ! -f "$TYPE/azuredeploy-parameters.json" ]; then
26 echo "$TYPE/azuredeploy-parameters.json missing"
27 exit 1
28 fi
29 fi
30
31 EXISTS_COUNT=`az group list --query "[?name=='$RESOURCE_GROUP']" | wc -l`
32 if [ $EXISTS_COUNT -ne 1 ] ; then
33 echo "$RESOURCE_GROUP already exists"
34 exit 1
35 fi
36
37 az group create --location centralus --name $RESOURCE_GROUP
38 if [ ! -z "$SSH_KEY" ]; then
39 echo Deploying with parameters...
40 az group deployment create --name burrito01 --no-wait --template-file $TYPE/azuredeploy.json --resource-group $RESOURCE_GROUP --parameters "{\"admin-username\":{\"value\":\"$USERNAME\"},\"ssh-public-key\":{\"value\":\"$SSH_KEY\"}}"
41 else
42 echo Deploying with parameter file...
43 az group deployment create --name burrito01 --no-wait --template-file $TYPE/azuredeploy.json --resource-group $RESOURCE_GROUP --parameters @$TYPE/azuredeploy-parameters.json
44 fi
45