Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonConfig explicitly takes Azure SDK credential, client option and additional provider configs from caller #346

Merged
merged 3 commits into from
Jan 30, 2023

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Jan 29, 2023

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 the azidentity.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 use aztfy, 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 that azidentity.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 on aztfy. Especially, e.g. a developer wants to make aztfy 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 the aztfy itself, which include API calls made by azlist and aztft (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 the CommonConfig to allow the caller to specify provider configs via key-value pairs. This will then be expanded to the generated provider.tf during the importing.

@magodo magodo requested review from ms-henglu and stemaMSFT January 29, 2023 07:10
@magodo magodo added the enhancement New feature or request label Jan 29, 2023
@magodo magodo merged commit 69274d8 into Azure:main Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants