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

Terraform and Azure API locations inconsistency #7906

Closed
gek0 opened this issue Jul 27, 2020 · 8 comments · Fixed by #8217
Closed

Terraform and Azure API locations inconsistency #7906

gek0 opened this issue Jul 27, 2020 · 8 comments · Fixed by #8217
Assignees
Labels
provider upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Milestone

Comments

@gek0
Copy link

gek0 commented Jul 27, 2020

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 ❓ How come the locations are not the same API <-> provider?

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

@jackofallops
Copy link
Member

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.

@rjshrjndrn
Copy link

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

@tombuildsstuff tombuildsstuff added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Aug 17, 2020
@rjshrjndrn
Copy link

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

@andydkelly-ig
Copy link

@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.

@tombuildsstuff
Copy link
Contributor

@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

@tombuildsstuff tombuildsstuff added this to the v2.25.0 milestone Aug 18, 2020
@rjshrjndrn
Copy link

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

@ghost
Copy link

ghost commented Aug 27, 2020

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 ...

@ghost
Copy link

ghost commented Sep 24, 2020

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!

@ghost ghost locked and limited conversation to collaborators Sep 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Projects
None yet
5 participants