Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Created November 7, 2020 02:29
Show Gist options
  • Save PradeepLoganathan/7de35313f569f4b071f589dae14b9f6a to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/7de35313f569f4b071f589dae14b9f6a to your computer and use it in GitHub Desktop.
tfstate_rg='remote-tfstate'
tfstate_ac=$(az storage account list --resource-group ${tfstate_rg} | jq .[0])
tfstate_account_name=$(echo $tfstate_ac | jq .name -r)
tfstate_account_key=$(az storage account keys list --resource-group ${tfstate_rg} --account-name ${tfstate_account_name} | jq .[0].value -r)
tf_state_container='terraform_state'
tf_state_keyname='key=myremotetf.tfstate'
terraform init \
-backend-config="storage_account_name=${tfstate_account_name}" \
-backend-config="container_name=${tf_state_container}" \
-backend-config="access_key=${tfstate_account_key}" \
-backend-config="${tf_state_keyname}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment