Multi-stage Terraform pattern
Jon Abbott
Infrastructure as code: declare cloud and SaaS resources in versioned files, then plan and apply changes through one consistent workflow.
A multi-stage Terraform pattern: run Terraform more than once in a CI/CD pipeline, with an application release between the stages.
Event Grid validates the Azure Function endpoint when the subscription is created — function code must already exist, not just the Function App.
Azure rejects the subscription while polling CreateOrUpdate — Terraform exits with code 1.
Endpoint validation
…/functions/<FunctionName>
eventgrid_subscriptions_enabled = false)
Conditionally include the subscription until the function endpoint can pass validation.
resource "azurerm_eventgrid_event_subscription" "internal" {
count = var.eventgrid_subscriptions_enabled ? 1 : 0
name = "evgs-${var.name}-internal"
scope = azurerm_eventgrid_topic.main.id
azure_function_endpoint {
function_id = local.subscriber_endpoint
}
}
Terraform Sandwich