Sanitize resourceManager endpoint to work around ARM metadata service inconsistencies #1264
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.
Community Note
Description
The ARM metadata service unfortunately returns the
resourceManagerendpoint in an inconsistent format between clouds. In Azure Public, it is returned with a trailing slash:https://management.azure.com/metadata/endpoints?api-version=2022-09-01
However, in Azure US Government, it is returned without the trailing slash:
https://management.usgovcloudapi.net/metadata/endpoints?api-version=2022-09-01
It seems that for the AzureRM Terraform Provider we require the environment to be initialized without the trailing slash. In fact, the built-in Azure Public environment (when not initializing the environment through the metadata endpoint) is also missing the trailing slash:
go-azure-sdk/sdk/environments/azure_public.go
Line 20 in 623b588
If the trailing slash is present, users have reported issues such as hashicorp/terraform-provider-azurerm#29819
Given how many dependencies other external clients might have on the ARM metadata service, it's likely easier to simply sanitize the input here rather than pressing for it to be changed on the ARM side.
This is a (please select all that apply):
Related Issue(s)
Fixes hashicorp/terraform-provider-azurerm#29819
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Note
If this PR changes meaningfully during the course of review please update the title and description as required.