-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-infra.sh
executable file
·38 lines (27 loc) · 984 Bytes
/
deploy-infra.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
#!/bin/bash
set -e
# infrastructure deployment properties
PROJECT_NAME="$1"
LOCATION="$2"
if [ "$PROJECT_NAME" == "" ]; then
echo "No project name provided - aborting"
exit 0;
fi
if [[ $PROJECT_NAME =~ ^[a-z0-9]{5,10}$ ]]; then
echo "project name $PROJECT_NAME is valid"
else
echo "project name $PROJECT_NAME is invalid - only numbers and lower case min 5 and max 10 characters allowed - aborting"
exit 0;
fi
RESOURCE_GROUP="$PROJECT_NAME"
AZURE_CORE_ONLY_SHOW_ERRORS="True"
if [ $(az group exists --name $RESOURCE_GROUP) = false ]; then
echo "creating resource group $RESOURCE_GROUP..."
az group create -n $RESOURCE_GROUP -l $LOCATION -o none
echo "resource group $RESOURCE_GROUP created"
else
echo "resource group $RESOURCE_GROUP already exists"
LOCATION=$(az group show -n $RESOURCE_GROUP --query location -o tsv)
fi
az deployment group create -g $RESOURCE_GROUP -f ./infrastructure/main.bicep \
-p projectName=$PROJECT_NAME