Fix AzureRM state backend Azure CLI support #20809
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been trying to use the azurerm state backend with Azure CLI to no avail with terraform v0.11.13.
I've documented my conclusions on a related issue in #18325 (comment)
After more investigation and some
git blame
commands, I've traced down the introduction of the problem to PR #19465The PR simply toggles the feature flag for Azure CLI support, relying on the implementation of github.com/hashicorp/go-azure-helpers/authentication which has proven its worth in the azure terraform provider.
However, there is a (legacy?) dragon lurking in the code in the form of the following if-statement:
This if-statement prevents usage of the Azure CLI as an authentication method, since in that case you would only provide the
storage_account_name
,container_name
andkey
. That obviously does not satisfy the above condition.I can't find any evidence that the changes in that PR were verified/tested manually, and there also aren't any automated tests that cover Azure CLI usage with the azurerm state backend.
I'm inclined to think the if-statement should simply be removed. All tests still pass after removing it.
Disclaimer: I would like to add a unit test to cover Azure CLI usage for the future, but I'm too much of a golang noob to actually be able to do it. Any help would be appreciated.