Created
June 20, 2024 19:17
-
-
Save sebnyberg/a02cee55b2979949ffb0bd9b4f93f490 to your computer and use it in GitHub Desktop.
Azure stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# findskus.sh - Find SKUs that support disk encryption, ephemeral disk, and | |
# have at least two availability zones. | |
# | |
# Usage: findskus.sh [memoryGB] [location] | |
# | |
set -euo pipefail | |
if [[ $# -ne 2 ]]; then | |
echo "Usage: $0 [memoryGB] [location]" >&2 | |
echo "Example: $0 16 southcentralus" >&2 | |
exit 1 | |
fi | |
if ! command -v jq &> /dev/null; then | |
echo "This script requires jq. Please install it and try again." >&2 | |
exit 1 | |
fi | |
memgb=${1} | |
location=${2} | |
echo "Finding SKUs with ${memgb}GB memory, ephemeral disk, disk encryption," | |
echo "and at least two availability zones in ${location}..." | |
az vm list-skus -l "${location}" -o json \ | |
| jq --arg memoryGB "${memgb}" '.[] | select( | |
(.capabilities | length > 0) and | |
(.capabilities[] | select(.name == "MemoryGB" and .value == $memoryGB )) and | |
(.capabilities[] | select(.name == "EphemeralOSDiskSupported" and .value == "True")) and | |
(.capabilities[] | select(.name == "EncryptionAtHostSupported" and .value == "True")) and | |
(.locationInfo[].zones | length >= 2) and | |
(.restrictions[].restrictionInfo.zones | length <= 1) | |
) | { | |
"zones": .locationInfo[].zones, | |
"restrictedZones": .restrictions[].restrictionInfo.zones, | |
"size": .size, | |
"cpuKind": (.capabilities[] | select(.name == "CpuArchitectureType" ) | .value ), | |
"vCPUs": (.capabilities[] | select(.name == "vCPUs" ) | .value ), | |
"memoryGB": (.capabilities[] | select(.name == "MemoryGB" ) | .value ) | |
}' |
Author
sebnyberg
commented
Jun 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment