Workaround for "Error: invalid value for name (EventGrid Topics)" during Cortex Cloud Azure Outpost Deployment
Symptom
Upon running the Terraform script to deploy Cortex Cloud Azure Outpost, the following error is encountered:│ Error: invalid value for name (EventGrid Topics name must be 3 - 128 characters long, contain only letters, numbers and hyphens.)│ │ with module.location["ukwest"].azurerm_eventgrid_system_topic.eventgrid_topic,│ on azure_outpost_cwp_agentless_single_region/resources-azurerm-eventgrid-system-topic.tf line 2, in resource "azurerm_eventgrid_system_topic" "eventgrid_topic":│ 2: name = "${var.subscription_name}-eg-topic-${var.location}"│
Environment
- Cortex Cloud (Tested on v1.2 and before)
- Microsoft Azure CSP
- Azure Subscription name containing a special character (except hyphen)
Cause
The root cause is an Azure Subscription name containing a special character (excluding hyphens). The Subscription name is used to name other resources, which do not allow the same naming conventions. Therefore a modification to the Terraform script is necessary for successful onboarding.
Resolution
- Modify the following 2 Terraform files as described:
resources-azurerm-eventgrid-event-subscription.tf
Original Line:name = "${var.subscription_name}-bc-eg-sub-${var.location}"
Updated Line:name = "${replace(var.subscription_name, "_", "-")}-bc-eg-sub-${var.location}"
resources-azurerm-eventgrid-system-topic.tf
Original Line: name ="${var.subscription_name}-eg-topic-${var.location}"
Updated Line: name ="${replace(var.subscription_name, "_", "-")}-eg-topic-${var.location}" - If the Subscription name contains multiple special characters, nested replaces will be necessary. For example:
name = "${replace(replace(var.subscription_name, "_", "-"), "*", "-")}-eg-topic-${var.location}" - Apply the Terraform configuration.
Additional Information
These changes replace all underscores in a Subscription ID with hyphens, which are allowed in EventGrid Topic names. The nested replace line replaces all underscores and asterisks.