-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
feature: optionally enhanced location validation #6927
Conversation
if err != nil { | ||
return nil, err | ||
} | ||
resp, err := client.Do(req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this intentionally doesn't use Azure/go-autorest since we don't need it here (it's an unauthorized endpoint, and logging this isn't super valuable)
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" { ```
eaa0556
to
4e8b906
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
THou i wonder if we should add this property to the docs? |
I'll add a section to the changelog for now, if we turn this on by default then it's probably worth documenting more broadly |
This has been released in version 2.11.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.11.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! |
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 duringterraform 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
totrue
.Example before/with this feature disabled:
Example with this feature enabled: