Azure / Azure/arm-ttk

Location Should Not Be Hardcoded - Allowed Values - Question

Open
#711 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PowerShell
Stars
468
Forks
208
PR merge metrics
No merged PRs in 30d

Description

First off, this is not a bug more a question / guidance request.

I have a param for resource location, that due to restrictions in Azure needs to limit the possible inputs. If I follow ARM-TTK best practice I should set the defaultValue to resourceGroup().location or similar and then the template passes ARM. However this could result in an incorrect deployment. However if I set the defaultValue to one of the allowedValues ARM-TTK will fail this test.

I can disable the Location test, but then I don't have the protection it provides in the rest of the template.

So my question is should the Location test, take into account allowed values?

PS This might be done for corporate policy, not just Azure limitations.

"location": {
"type": "string",
"defaultValue": "uksouth",
"metadata": {
"description": "The location of the resources created, this is limited to only the locations that support linked Log Analytics and Automation Account."
},
"allowedValues": [
"eastus",
"westus2",
"canadacentral",
"australiasoutheast",
"southeastasia",
"centralindia",
"japaneast",
"uksouth",
"westeurope",
"usgovvirginia"
]
},

[-] Location Should Not Be Hardcoded 119ms
RuntimeException: The defaultValue of the location parameter in the main template must not be a specific location.
The default value must be [resourceGroup().location], [deployment().location] or 'global'. It is "uksouth"

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the ARM-TTK test named “Location Should Not Be Hardcoded” and review how it evaluates a parameter’s defaultValue alongside allowedValues. Use the provided location parameter and failure output as the reproduction case; done means the test’s expected behavior for restricted locations is decided and covered by the relevant test validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud, testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.