This commit introduces a new optional feature, for the enhanced validation of Locations.
The Azure MetaData Service - that is: /metadata/endpoints?api-version=2018-01-01 returns
information about the locations which are suppported on the Azure Instance that we're
connected to. As such, this commit optionally caches this information with the intent of
providing more granular validation - to avoid cases where an unsupported location is specified.
This allows Terraform to catch this error during `terraform plan` - rather than failing during
`terraform apply` - which is a better user experience.
This functionality is disabled by default at this time - but can conditionally be enabled
via the Feature Flag using the Environment Variable `ARM_PROVIDER_ENHANCED_VALIDATION` to `true`.
Example before/with this feature disabled:
```
$ ARM_PROVIDER_ENHANCED_VALIDATION=false tf plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# azurerm_resource_group.test will be created
+ resource "azurerm_resource_group" "test" {
+ id = (known after apply)
+ location = "chinanorth"
+ name = "tom-dev99"
+ timeouts {
+ create = "60m"
}
}
Plan: 1 to add, 0 to change, 0 to destroy
```
Example with this feature enabled:
```
$ ARM_PROVIDER_ENHANCED_VALIDATION=true tf plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
Error: "chinanorth" 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,uknorth,uksouth2,uksouth,ukwest,francecentral,francesouth,australiacentral,australiacentral2,uaecentral,uaenorth,southafricanorth,southafricawest,switzerlandnorth,switzerlandwest,germanynorth,germanywestcentral,norwayeast,norwaywest"
on main.tf line 5, in resource "azurerm_resource_group" "test":
5: resource "azurerm_resource_group" "test" {
```