bicep icon indicating copy to clipboard operation
bicep copied to clipboard

False positive for use-resource-id-functions, should not fail on resourceGroup().id or similar

Open StephenWeatherford opened this issue 3 years ago • 5 comments

param vaultName string = 'vault${uniqueString(resourceGroup().id)}'
param diskName string = 'disk${uniqueString(resourceGroup().id)}'

resource backupVault 'Microsoft.DataProtection/backupVaults@2021-01-01' existing = {
  name: vaultName
}

resource backupInstance 'Microsoft.DataProtection/backupvaults/backupInstances@2021-01-01' = {
  parent: backupVault
  name: diskName
  properties: {
    policyInfo: {
      policyParameters: {
        dataStoreParametersList: [
          {
            objectType: 'AzureOperationalStoreParameters'
            dataStoreType: 'OperationalStore'
            resourceGroupId: resourceGroup().id   // <<<<<<<<<<<<<<<<<<<<<<< SHOULDN'T FAIL BUT DOES
          }
        ]
      }
    }
  }
}

StephenWeatherford avatar Aug 24 '22 18:08 StephenWeatherford

Should probably pass if top-level expression is a call to any of these: resourceGroup(), deployment(), environment(), subscription(), tenant() or managementGroup()

Another possibility is to reverse the logic and only fail if the top-level expression is something like a concat or string interpolation.

StephenWeatherford avatar Aug 29 '22 21:08 StephenWeatherford

sw/8104-resid-rgid

StephenWeatherford avatar Aug 30 '22 17:08 StephenWeatherford

@StephenWeatherford is this the same as https://github.com/Azure/bicep/issues/11051?

ohads-MSFT avatar Sep 26 '23 17:09 ohads-MSFT

Unfortunately no. This one is that the linter rule doesn't realize the function+property resourceGroup().id returns a valid resource ID that should succeed.

StephenWeatherford avatar Sep 26 '23 22:09 StephenWeatherford

Unfortunately no. This one is that the linter rule doesn't realize the function+property resourceGroup().id returns a valid resource ID that should succeed.

Oh, and the one I linked to is about the property itself not actually denoting a resource ID (rather a subscription ID), and hence added to the ignore list in the PR fix?

ohads-MSFT avatar Sep 27 '23 13:09 ohads-MSFT