Skip to content

SAIFTRBL0013 ยท permalink

Terraform plan fails: network_rules_default_action is null

One-sentence summary: Setting blob_storage_settings.contributor_group_id to a data.azuread_group lookup instead of a literal object ID fails the Organization Policy Check and cascades into null-value errors deep in the storage account module.


๐Ÿšจ Symptom

Enabling the blob storage feature flag on the saif-appservices module and running terraform plan (locally or in the Deploy pipeline) fails with:

โ•ท
โ”‚ Error: Invalid function argument
โ”‚
โ”‚   on .terraform/modules/saif-appservices.storage.storageaccount/modules/storageaccount/variables.tf line 199, in variable "network_rules_default_action":
โ”‚  199:   condition = contains(["Allow", "Deny"], var.network_rules_default_action)
โ”‚     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
โ”‚     โ”‚ while calling contains(list, value)
โ”‚     โ”‚ var.network_rules_default_action is null
โ”‚
โ”‚ Invalid value for "value" parameter: argument must not be null.
โ•ต
โ•ท
โ”‚ Error: Iteration over null value
โ”‚
โ”‚   on .terraform/modules/saif-appservices.storage.storageaccount/modules/storageaccount/variables.tf line 211, in variable "network_rules_bypass":
โ”‚  210:   condition = alltrue([
โ”‚  211:     for service in var.network_rules_bypass : contains(["AzureServices", "Logging", "Metrics", "None"], service)
โ”‚  212:   ])
โ”‚     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
โ”‚     โ”‚ var.network_rules_bypass is null
โ”‚
โ”‚ A null value cannot be used as the collection in a 'for' expression.
โ•ต
Operation failed: failed running terraform plan (exit 1)

This shows up in the Deploy pipeline's terraform plan/terraform apply step, or locally when running Terraform against infra/api/app.generated.tf.


๐Ÿ“Œ Applies to

Aspect Value
Component Terraform โ€” saif-apiservice module, blob storage feature flag
Forge versions saif-apiservice module >= 3.0.0, < 4.0.0
Related versions Check the version compatibility matrix

๐Ÿง  Cause

blob_storage_settings.contributor_group_id was set by looking up an Entra ID group at plan time, e.g.:

contributor_group_id = data.azuread_group.customer_team.object_id

Data-source lookups aren't allowed in this position โ€” the Organization Policy Check rejects plans that resolve group membership this way. When that lookup can't be evaluated, the module's other feature-flag-conditional inputs (including network_rules_default_action and network_rules_bypass) can't be computed either, so they come through as null and Terraform fails deep inside the storageaccount submodule with the errors above.


โœ… Fix

  1. Look up your team's Entra ID group object ID once, instead of resolving it in Terraform:

    az ad group show --group "<display name>" --query id -o tsv
    
  2. Replace the data.azuread_group reference with the literal GUID in blob_storage_settings:

    feature_flags = {
      enable_blob_storage = true
      blob_storage_settings = {
        containers            = ["documents", "uploads", "archives"]
        contributor_group_id  = "12345678-1234-1234-1234-123456789abc" # hardcoded, not a data source
      }
    }
    
  3. Remove the now-unused data "azuread_group" block from app.generated.tf.


๐Ÿ”ฌ Verify

terraform plan completes without the Invalid function argument / Iteration over null value errors, and shows the expected storage account, container, and RBAC role assignment resources to add.