Skip to content

Resources with Space in the name generate bad TF #259

@emilwester-optimizely

Description

@emilwester-optimizely

Some resources in azure have space in them. This generates bad TF and errors when doing terraform apply

TF code:

resource "azurerm_monitor_smart_detector_alert_rule" "res-486" {
  description         = "Failure Anomalies notifies you of an unusual rise in the rate of failed HTTP requests or dependency calls."
  detector_type       = "FailureAnomaliesDetector"
  frequency           = "PT1M"
  name                = "Failure Anomalies - REMOVED"
  resource_group_name = "REMOVED"
  scope_resource_ids  = ["/subscriptions/REMOVED/resourcegroups/REMOVED/providers/microsoft.insights/components/REMOVED"]
  severity            = "Sev3"
  action_group {
    ids = ["/subscriptions/REMOVED/resourcegroups/REMOVED/providers/microsoft.insights/actiongroups/application insights smart detection"]
  }
  depends_on = [
    azurerm_resource_group.res-0,
  ]
}

TF apply response:

Error: ID was missing the `actionGroups` element
│ 
│   with azurerm_monitor_smart_detector_alert_rule.res-486,
│   on main.tf line 837, in resource "azurerm_monitor_smart_detector_alert_rule" "res-486":
│  837:     ids = ["/subscriptions/REMOVED/resourcegroups/REMOVED/providers/microsoft.insights/actiongroups/application insights smart detection"]

I have tried replacing the space with + and %20 but it still fails.

this is related to:
Azure/azure-cli#12885
but there is a workaround in comment:
Azure/azure-cli#12885 (comment)

Can we implement a similar workaround until fixed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions