-
Notifications
You must be signed in to change notification settings - Fork 7
/
azure_setup.sh
62 lines (50 loc) · 1.58 KB
/
azure_setup.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -x
# Get the suscription ID
subscriptionId="$(az account list --query "[?isDefault].id" --output tsv)"
echo $subscriptionId
# Create SP
az ad sp create-for-rbac --name ${1}-sp \
--role Contributor \
--scopes /subscriptions/${subscriptionId}
appId="$(az ad sp list --display-name ${1}-sp --query "[].id" --output tsv)"
# We need to be able to asign
cat <<EOF > mapt-aks-role.json
{
"Name": "Mapt AKS Operator",
"IsCustom": true,
"Description": "Can create aks clusters with mapt features.",
"Actions": [
"Microsoft.Authorization/roleAssignments/*"
],
"NotActions": [],
"DataActions": [],
"NotDataActions": [],
"AssignableScopes": [
"/subscriptions/${subscriptionId}"
]
}
EOF
az role definition create --role-definition mapt-aks-role.json
az role assignment create --assignee ${appId} \
--role "Mapt AKS Operator" \
--scope "/subscriptions/${subscriptionId}"
# Create rg for blob container for pulumi state
san=$(echo "${1}maptsa" | tr -cd '[:alnum:]')
az group create \
--name ${1}-mapt-rg \
--location westeurope
az storage account create \
--name ${san} \
--resource-group ${1}-mapt-rg \
--location westeurope \
--sku Standard_ZRS \
--encryption-services blob \
--allow-blob-public-access false
az storage container create \
--account-name ${san} \
--name ${1}-mapt-state \
--auth-mode login
# Get az storage account key to set on AZURE_STORAGE_KEY
# https://www.pulumi.com/docs/concepts/state/#azure-blob-storage
az storage account keys list --account-name ${san}