vuls: init at 0.27.0
[NixPkgs.git] / nixos / maintainers / scripts / azure-new / boot-vm.sh
blob1ce3a5f9db1e77c089972246b9298180a7a1b1dd
1 #!/usr/bin/env bash
2 set -euo pipefail
3 set -x
5 image="${1}"
6 location="westus2"
7 group="nixos-test-vm"
8 vm_size="Standard_D2s_v3"; os_size=42;
10 # ensure group
11 az group create --location "westus2" --name "${group}"
12 group_id="$(az group show --name "${group}" -o tsv --query "[id]")"
14 # (optional) identity
15 if ! az identity show -n "${group}-identity" -g "${group}" &>/dev/stderr; then
16 az identity create --name "${group}-identity" --resource-group "${group}"
19 # (optional) role assignment, to the resource group, bad but not really great alternatives
20 identity_id="$(az identity show --name "${group}-identity" --resource-group "${group}" -o tsv --query "[id]")"
21 principal_id="$(az identity show --name "${group}-identity" --resource-group "${group}" -o tsv --query "[principalId]")"
22 until az role assignment create --assignee "${principal_id}" --role "Owner" --scope "${group_id}"; do sleep 1; done
24 # boot vm
25 az vm create \
26 --name "${group}-vm" \
27 --resource-group "${group}" \
28 --assign-identity "${identity_id}" \
29 --size "${vm_size}" \
30 --os-disk-size-gb "${os_size}" \
31 --image "${image}" \
32 --admin-username "${USER}" \
33 --location "westus2" \
34 --storage-sku "Premium_LRS" \
35 --ssh-key-values "$(ssh-add -L)"