Terraform-provider-azurerm: Terraform and Azure API locations inconsistency

Created on 27 Jul 2020  ·  8Comments  ·  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.12.20
+ provider.azurerm v2.20.0

Affected Resource(s)

  • ALL

    Terraform Configuration Files

For example RG resource, but everything else fails. RG is only the prerequisite

provider "azurerm" {
  version         = "~> 2"
  tenant_id       = var.tenant_id
  subscription_id = var.subscription_id
  features {}
}

resource "azurerm_resource_group" "resource_group" {
  name     = var.resource_group_name
  location = var.resource_group_location
  tags     = var.tags
}

Debug Output

Panic Output

Expected Behavior

Terraform should create resources in desired location/region

Actual Behavior

Terraform does not support the south/west/central India locations. They are called India south/west/central in terraform which is not valid on Azure site
https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/internal/location/validation_test.go#L167

If we set location/region name to Terraform format (validation above), we got an error originating from Azure

Error: Error creating Resource Group "<SOME_RG>": resources.GroupsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="LocationNotAvailableForResourceGroup" Message="The provided location 'indiasouth' is not available for resource group. List of available regions is 'centralus,eastasia,southeastasia,eastus,eastus2,westus,westus2,northcentralus,southcentralus,westcentralus,northeurope,westeurope,japaneast,japanwest,brazilsouth,australiasoutheast,australiaeast,westindia,southindia,centralindia,canadacentral,canadaeast,uksouth,ukwest,koreacentral,koreasouth,francecentral,southafricanorth,uaenorth,australiacentral,switzerlandnorth,germanywestcentral,norwayeast'."

  on 10-main.tf line 8, in resource "azurerm_resource_group" "resource_group":
   8: resource "azurerm_resource_group" "resource_group" {

Which is reasonable and expected since

08:44 $ az account list-locations -o table
DisplayName           Latitude    Longitude    Name
--------------------  ----------  -----------  ------------------
...
South India           12.9822     80.1636      southindia
Central India         18.5822     73.9197      centralindia
West India            19.088      72.868       westindia
...

But trying to use the valid location/region on Azure fails in Terraform validation

Error: "southindia" was not found in the list of supported Azure Locations: "westus,westus2,eastus,centralus,centraluseuap,southcentralus,northcentralus,westcentralus,eastus2,eastus2euap,brazilsouth,brazilus,northeurope,westeurope,eastasia,southeastasia,japanwest,japaneast,koreacentral,koreasouth,indiasouth,indiawest,indiacentral,australiaeast,australiasoutheast,canadacentral,canadaeast,uksouth,ukwest,francecentral,francesouth,australiacentral,australiacentral2,uaecentral,uaenorth,southafricanorth,southafricawest,switzerlandnorth,switzerlandwest,germanynorth,germanywestcentral,norwayeast,norwaywest,brazilsoutheast"

  on 10-main.tf line 8, in resource "azurerm_resource_group" "resource_group":
   8: resource "azurerm_resource_group" "resource_group" {

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000

Additional info

The most interesting thing is that centralindia is valid even when I set it in terraform and create the resource (cannot found it in the validation test?) but southindia/westindia are not :question: How come the locations are not the same API <-> provider?

Location differences. Terraform on the left, Azure on the right
image (1)

provider upstream-microsoft

Most helpful comment

@andydkelly-ig @rjshrjndrn as @jackofallops has mentioned unfortunately this incorrect data is coming from the Azure API - Terraform is now using this data to validate regions (to be able to offer enhanced validation at 'plan' time rather than crashing during an 'apply').

Until this is fixed on the Azure-side (which we've raised with Microsoft) you can opt-out of this by setting the environment variable ARM_PROVIDER_ENHANCED_VALIDATION to false - we'll also look to include a temporary fix for this in an upcoming release so that this isn't necessary

All 8 comments

By way of update. This is blocked until we get a resolution from MSFT on the locations API returning incorrect values for the India locations. Once we get reliable data back, we'll be able to merge @favoretti 's PR to correct the tests.

This is kind of absolutely weird, to change a crucial API without any backward compatibility. I guess MSFT has their own reasons.

@tombuildsstuff is there any alternate approach to do this? Sorry to pester, but it's kind of a priority :(

@tombuildsstuff is there any alternate approach to do this? Sorry to pester, but it's kind of a priority :(

The only way i got around this for making changes to our Production infrastructure was to go back to version 2.19.0 of the Azure Provider. Sadly that won't work if you need features added since 2.20.0 forwards, but for us was the only way to push required changes out.

@andydkelly-ig @rjshrjndrn as @jackofallops has mentioned unfortunately this incorrect data is coming from the Azure API - Terraform is now using this data to validate regions (to be able to offer enhanced validation at 'plan' time rather than crashing during an 'apply').

Until this is fixed on the Azure-side (which we've raised with Microsoft) you can opt-out of this by setting the environment variable ARM_PROVIDER_ENHANCED_VALIDATION to false - we'll also look to include a temporary fix for this in an upcoming release so that this isn't necessary

@AndreasAbdi @tombuildsstuff thanks for your response.
@tombuildsstuff Will ARM_PROVIDER_ENHANCED_VALIDATION=false skip other problems if found?

This has been released in version 2.25.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.25.0"
}
# ... other configuration ...

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings