Azure / arm-ttk

Azure Resource Manager Template Toolkit
https://aka.ms/arm-ttk
MIT License
431 stars 186 forks source link

The issue "The resource 'xxx' is not defined in the template" is not detected #750

Closed qingshanJBHIFI closed 6 months ago

qingshanJBHIFI commented 1 year ago

Issue

We used separate templates for different resource deployment, we put APIM in apim.tempalte.json:

{
      "apiVersion": "2023-03-01-preview",
      "name": "[parameters('apimServiceName')]",
      "location": "[parameters('location')]",
      "type": "Microsoft.ApiManagement/service",
      "sku": {
        "name": "[parameters('sku')]",
        "capacity": "[parameters('skuCount')]"
      },
      "zones": "[parameters('availabilityZones')]",
      "identity": {
        "type": "SystemAssigned"
      },
}

and the diagnostics into azuremonitor.template.json:

{
      "type": "Microsoft.ApiManagement/service/diagnostics",
      "apiVersion": "2022-09-01-preview",
      "name": "[concat(parameters('apimServiceName'), '/azuremonitor')]",
      "dependsOn": [
        "[resourceId('Microsoft.ApiManagement/service/loggers', parameters('apimServiceName'), 'azuremonitor')]"
      ],
      "dependsOn": [
        "[resourceId('Microsoft.ApiManagement/service', parameters('apimServiceName'))]"
      ],
      "properties": {
        "logClientIp": true,
        "alwaysLog": "allErrors",
        "loggerId": "[resourceId('Microsoft.ApiManagement/service/loggers', parameters('apimServiceName'), 'azuremonitor')]",
        "sampling": {
          "samplingType": "fixed",
          "percentage": "[parameters('samplingRate')]"
        }
    }
}

then we have a main tempalte to deploy those two tempates, in azuremonitor.template.json we added dependsOn, but the APIM service is not defined in the current template file, the deployment will fail.

When I run the arm-ttk, it didn't report this error.

Expectation

arm-ttk should be able to report this issue.

vidapour commented 6 months ago

TTK is meant to verify best-practices compliance. It does not check for syntax, dependencies, APIs, etc., for your services.

These are likely closer to what you're looking for: template deployment what-if // validate REST API

Thanks!