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

Add support for all Azure Clouds #130

Merged
merged 3 commits into from
Mar 28, 2024

Conversation

frey0814
Copy link

To support aad authentication in other Azure Clouds, the scope needs to be updated for the the destination Azure Cloud.

To support detection of which cloud is being used, the code references the Terraform azurerm provider environment variable ARM_ENVIRONMENT.

It is likely this URL could be grabbed from the Azure go SDK since it is available via the az CLI.

az cloud show --name AzureCloud |grep ossrdbms
    "ossrdbmsResourceId": "https://ossrdbms-aad.database.windows.net",
az cloud show --name AzureChinaCloud |grep ossrdbms
    "ossrdbmsResourceId": "https://ossrdbms-aad.database.chinacloudapi.cn",
az cloud show --name AzureUSGovernment |grep ossrdbms
    "ossrdbmsResourceId": "https://ossrdbms-aad.database.usgovcloudapi.net"
az cloud show --name AzureGermanCloud |grep ossrdbms
    "ossrdbmsResourceId": "https://ossrdbms-aad.database.cloudapi.de"

I have been able to test this successfully using AzureCloud and AzureChinaCLoud.

Without this fix when running against AzureChinaCloud terraform would generate the following error when it tries to refresh the resource.

│ Error: failed to get token from Azure AD DefaultAzureCredential: failed to acquire a token.
│ Attempted credentials:
│       EnvironmentCredential: missing environment variable AZURE_TENANT_ID
│       WorkloadIdentityCredential: no client ID specified. Check pod configuration or set ClientID in the options
│       ManagedIdentityCredential: managed identity timed out. See https://aka.ms/azsdk/go/identity/troubleshoot#dac for more information
│       AzureCLICredential: ERROR: AADSTS500011: The resource principal named https://ossrdbms-aad.database.windows.net/ was not found in the tenant named PVUECN. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant. Trace ID: 982556b8-904c-402e-b93e-935933478800 Correlation ID: ccd73ba7-a547-4a08-b614-8fddd1f41fce Timestamp: 2024-03-26 19:35:16Z
│ Interactive authentication is needed. Please run:
│ az login --scope https://ossrdbms-aad.database.windows.net/.default
│
│       AzureDeveloperCLICredential: Azure Developer CLI not found on path
│
│   with provider["registry.terraform.io/petoju/mysql"].aad,

@petoju petoju merged commit 2795da3 into petoju:master Mar 28, 2024
13 checks passed
@petoju
Copy link
Owner

petoju commented Mar 28, 2024

I should have probably asked for updated doc, but I merged and already released it in 3.0.53.

@frey0814
Copy link
Author

frey0814 commented Mar 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants