A legacy Azure outpost Terraform template builds an Event Grid resource name from a subscription display name containing spaces and the resource-name validation fails. What should be corrected?
Select an answer to reveal the explanation.
Short Explanation
You can keep a subscription display name such as Claims Ops East; the defect is in the generated Event Grid name, so sanitize the Terraform resource-name expression to satisfy Azure’s rules. Don’t assume blanks are ignored or substitute a tenant region label with spaces, since neither corrects the generated name.
Full Explanation
Azure subscription display names can contain spaces, so you do not need to rename the subscription. The legacy template uses the display name to build an Event Grid resource name; when spaces flow into that derived value, Azure’s resource-name validation fails during apply. Sanitizing the generated Terraform resource-name expressions to meet Azure naming rules fixes the defect where the invalid name is constructed. Leaving the spaces in “Claims Ops East” preserves the problematic input, so validation can still fail. The claim that blanks in any display name are ignored is incorrect: the derived string is not made valid merely because it comes from a display name. Copying a tenant region label, including one with spaces, confuses that label with the source of the Event Grid name and can reproduce the same invalid characters. Exam caveat: the subscription display name itself may contain spaces; the generated resource name must satisfy Azure’s rules. Practical check: inspect the planned Event Grid name, apply the sanitizing expression, and rerun validation to confirm it passes without changing the subscription name.