Skip to content

Instantly share code, notes, and snippets.

@chris-moreton
Last active May 21, 2019 14:19
Show Gist options
  • Save chris-moreton/1ce5bd7ecd920dee6e05c08476921f16 to your computer and use it in GitHub Desktop.
Save chris-moreton/1ce5bd7ecd920dee6e05c08476921f16 to your computer and use it in GitHub Desktop.
Copy from one Azure Vault to Another, Replaceing Environment Name
SECRET_NAMES=(appeal-email-from appeal-email-to ccd-api ccd-case-worker-id ccd-jid ccd-tid docmosis-api-key docmosis-endpoint gaps2-service-sftp-private-key gaps2-service-sftp-private-key-preview hpkp-sya-sha-1 hpkp-sya-sha-2 hpkp-tya-sha-1 hpkp-tya-sha-2 idam-api idam-key-sscs idam-oauth-user idam-redirect idam-role idam-s2s-api idam-sscs-oauth2-client-secret idam-sscs-systemupdate-password idam-sscs-systemupdate-user idam-uid microservice-sscs-bulkscan notification-key notification-test-key postcode-lookup-token robotics-email-from robotics-email-to s2s-api s2s-micro sftp-dir sftp-host sftp-port sscs-asb-primary-send-and-listen-shared-access-key sscs-cor-idam-client-secret sscs-cor-idam-client-secret-test sscs-email-mac-secret-text sscs-failure-email-to sscs-s2s-secret tya-link tyacookiesecret smtp-host smtp-port)
for SECRET_NAME in "${SECRET_NAMES[@]}"
do
echo "Getting value from demo vault for $SECRET_NAME..."
az account set --subscription "DCD-CNP-Dev"
az keyvault secret show --vault-name "sscs-aat" --name "$SECRET_NAME" > secret.json
AAT_SECRET_VALUE=`jq .value < secret.json | sed -e 's/^"//' -e 's/"$//'`
SECRET_VALUE="${AAT_SECRET_VALUE//aat/ithc}"
echo "az keyvault secret set --vault-name \"sscs-ithc\" --name \"$SECRET_NAME\" --value=\"$SECRET_VALUE\"" >> secrets.txt
echo "Setting value in ithc vault"
az account set --subscription "DCD-CNP-QA"
az keyvault secret set --vault-name "sscs-ithc" --name "$SECRET_NAME" --value="$SECRET_VALUE"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment