Skip to content

Instantly share code, notes, and snippets.

@piratecarrot
Created November 17, 2021 01:15
Show Gist options
  • Save piratecarrot/d7ca573631c7eb6daee8077708383bb7 to your computer and use it in GitHub Desktop.
Save piratecarrot/d7ca573631c7eb6daee8077708383bb7 to your computer and use it in GitHub Desktop.
Add Google Workspace DNS records
#!/bin/bash
resourceGroup="my-resource-group"
sites=("test.com" "test.net" "test.org")
mailExchanges=("aspmx4.googlemail.com" "alt2.aspmx.l.google.com" "aspmx2.googlemail.com" "aspmx3.googlemail.com" "aspmx.l.google.com" "alt1.aspmx.l.google.com" "aspmx5.googlemail.com")
preferences=( 30 20 30 30 10 20 30 )
for site in ${sites[@]}; do
for i in ${!mailExchanges[@]}; do
az network dns record-set mx add-record \
--resource-group ${resourceGroup} \
--zone-name ${site} \
--record-set-name "@" \
--exchange ${mailExchanges[$i]} \
--preference ${preferences[$i]}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment