Azure / Azure/arm-ttk

Location Should Not Be Hardcoded test

Open
#310 4 comments 1 reaction 0 assignees View on GitHub
enhancement Needs: author feedback
Dominant language
PowerShell
Stars
468
Forks
208
PR merge metrics
No merged PRs in 30d

Description

"Location Should Not Be Hardcoded" test fails for some resources, when the parameter is using default value set to [resourceGroup().location]

E.g.
```
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
[...]
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for the resources."
}
}
},
"resources": [
//ServiceBus with Queue
{
"apiVersion": "2018-01-01-preview",
"name": "[parameters('serviceBusNamespaceName')]",
"type": "Microsoft.ServiceBus/namespaces",
"location": "[parameters('location')]",
"kind": "Messaging",
"sku": {
"name": "Basic"
},
[...]
}
```
passes the validation , but
```
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
[...]
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for the resources."
}
}
},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2019-05-01",
"name": "[parameters('logicAppName')]",
"location": "[parameters('location')]",
[...]
}
```
fails with
[-] Location Should Not Be Hardcoded (40 ms)
azuredeploy.json must use the location parameter, not resourceGroup().location (except when used as a default value in the main template)
The same error is thrown for "type": "Microsoft.Web/connections"

All ARM templates are main templates named azuredeploy.json

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.