Skip to content

Instantly share code, notes, and snippets.

@rproenca
Last active October 13, 2020 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rproenca/e80529eb8301a69ec140a678a25fc5f3 to your computer and use it in GitHub Desktop.
Save rproenca/e80529eb8301a69ec140a678a25fc5f3 to your computer and use it in GitHub Desktop.
A bash script that updates Azure Vault network ACLs given list of CIDRs addresses
#!/bin/bash
# This script updates Azure Vault network ACLs given list of IP Addresses in CIDR format
VAULT_NAME=$1; # Vault name
INPUT_FILENAME=cidr_list.txt
if [ -z $VAULT_NAME ]
then
printf "Incorrect usage. Please use: ./update.sh [vault_name]\n";
printf "Example: ./update.sh my-vault-tst\n";
else
IFS=$'\n' read -d '' -r -a cidr_list < $INPUT_FILENAME
for i in "${!cidr_list[@]}"
do
# Add a network rule to the network ACLs for a Key Vault
az keyvault network-rule add -n $VAULT_NAME --ip-address ${cidr_list[i]}
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment