CommonConfig
explicitly takes Azure SDK credential, client option and additional provider configs from caller
#346
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.
Previously, we were building the Azure SDK credential and client options internally as a step during
BaseMeta
construction. In order to support multiple auth methods, we were using theazidentity.NewDefaultAzureCredential()
from Azure Go SDK, which will retrieve the auth info from multiple sources, including env var, MSI, Azure CLI. So previously, users are allowed to either login against azure CLI then directly useaztfy
, or they can also export the env vars as are required by the azurerm provider, then we will internally re-export them to the corresponding names in context of Azure Go SDK so thatazidentity.NewDefaultAzureCredential
can recognize them.This (manipulating the environment variable within one process) is fine for a single user, which is most likely the only case for
aztfy
CLI users. However, this makes issues for other Go modules that depend onaztfy
. Especially, e.g. a developer wants to makeaztfy
to be a service to serve for different users (different tenant id, subscription id, etc). Manipulating the environment variables are not a choice then.This PR makes the
CommonConfig
to explicitly take a pre-built Azure SDK credential and the SDK client option object (to allow customization). These affects the client calls made by theaztfy
itself, which include API calls made byazlist
andaztft
(hence we've update them accordingly).While above changes doesn't affect how the provider do auth. In order to make it configurable instead of via env var, this PR adds a new field
ProviderConfig
in theCommonConfig
to allow the caller to specify provider configs via key-value pairs. This will then be expanded to the generatedprovider.tf
during the importing.