hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

Unable to apply Event Grid Subscription with scope of EG Domain #8802

Closed devops-lucina closed 4 years ago

devops-lucina commented 4 years ago

Community Note

Terraform (and AzureRM Provider) Version

v0.13.3

Affected Resource(s)

Terraform Configuration Files

resource "azurerm_eventgrid_event_subscription" "egds-daevtdrop" {
    name  = "egds-daevtdrop"
    scope = var.egd_phi_id # input to module

    azure_function_endpoint {
        function_id                         = azurerm_function_app.fn-daevtdrop.id
        max_events_per_batch                = 1
        preferred_batch_size_in_kilobytes   = 64
    }
}

Debug Output

?  terraform plan -out="dev.tfplan" -var-file="dev.tfvars"
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

module.dataprocessing.azurerm_resource_group.rg-dataprocessing: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-dataprocessing-dev]
module.integration.azurerm_resource_group.rg-integration: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-integration-dev]
module.integration.azurerm_eventgrid_domain.egd-phi: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-integration-dev/providers/Microsoft.EventGrid/domains/egd-phi-ledev]
module.dataprocessing.azurerm_application_insights.fn-daevtdrop-ai: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/microsoft.insights/components/fn-daevtdrop-ai-ledev]
module.dataprocessing.azurerm_app_service_plan.fn-daevtdrop-sp: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/Microsoft.Web/serverfarms/fn-daevtdrop-sp-ledev]
module.dataprocessing.azurerm_storage_account.stfndaevtdrop: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/Microsoft.Storage/storageAccounts/stfndaevtdropledev]
module.dataprocessing.azurerm_function_app.fn-daevtdrop: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/Microsoft.Web/sites/fn-daevtdrop-ledev]
module.dataprocessing.azurerm_eventgrid_event_subscription.egds-daevtdrop: Refreshing state... [id=/subscriptions/***/resourceGroups/rg-integration-dev/providers/Microsoft.EventGrid/Domains/egd-phi-ledev/providers/Microsoft.EventGrid/eventSubscriptions/egds-daevtdrop]

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.dataprocessing.azurerm_application_insights.fn-daevtdrop-ai will be updated in-place
  ~ resource "azurerm_application_insights" "fn-daevtdrop-ai" {
        app_id                                = "***"
        application_type                      = "other"
        daily_data_cap_in_gb                  = 100
        daily_data_cap_notifications_disabled = false
        disable_ip_masking                    = false
        id                                    = "/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/microsoft.insights/components/fn-daevtdrop-ai-ledev"
        instrumentation_key                   = (sensitive value)
        location                              = "eastus"
        name                                  = "fn-daevtdrop-ai-ledev"
        resource_group_name                   = "rg-dataprocessing-dev"
        retention_in_days                     = 90
        sampling_percentage                   = 100
      ~ tags                                  = {
          - "hidden-link:/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/Microsoft.Web/sites/fn-daevtdrop-ledev" = "Resource" -> null
        }
    }

  # module.dataprocessing.azurerm_eventgrid_event_subscription.egds-daevtdrop will be updated in-place
  ~ resource "azurerm_eventgrid_event_subscription" "egds-daevtdrop" {
        event_delivery_schema = "EventGridSchema"
        id                    = "/subscriptions/***/resourceGroups/rg-integration-dev/providers/Microsoft.EventGrid/Domains/egd-phi-ledev/providers/Microsoft.EventGrid/eventSubscriptions/egds-daevtdrop"
        included_event_types  = []
        labels                = []
        name                  = "egds-daevtdrop"
        scope                 = "/subscriptions/***/resourceGroups/rg-integration-dev/providers/Microsoft.EventGrid/Domains/egd-phi-ledev"

      ~ azure_function_endpoint {
          ~ function_id                       = "/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/Microsoft.Web/sites/fn-daevtdrop-ledev/functions/EventGridTriggerCSharp1" -> "/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/Microsoft.Web/sites/fn-daevtdrop-ledev"
            max_events_per_batch              = 1
            preferred_batch_size_in_kilobytes = 64
        }

        retry_policy {
            event_time_to_live    = 120
            max_delivery_attempts = 10
        }

        timeouts {}
    }

Plan: 0 to add, 2 to change, 0 to destroy.

------------------------------------------------------------------------

This plan was saved to: dev.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "dev.tfplan"

?  terraform apply "dev.tfplan"
module.dataprocessing.azurerm_application_insights.fn-daevtdrop-ai: Modifying... [id=/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/microsoft.insights/components/fn-daevtdrop-ai-ledev]
module.dataprocessing.azurerm_eventgrid_event_subscription.egds-daevtdrop: Modifying... [id=/subscriptions/***/resourceGroups/rg-integration-dev/providers/Microsoft.EventGrid/Domains/egd-phi-ledev/providers/Microsoft.EventGrid/eventSubscriptions/egds-daevtdrop]
module.dataprocessing.azurerm_application_insights.fn-daevtdrop-ai: Still modifying... [id=/subscriptions/***...ights/components/fn-daevtdrop-ai-ledev, 10s elapsed]
module.dataprocessing.azurerm_application_insights.fn-daevtdrop-ai: Modifications complete after 10s [id=/subscriptions/***/resourceGroups/rg-dataprocessing-dev/providers/microsoft.insights/components/fn-daevtdrop-ai-ledev]

Error: Error creating/updating EventGrid Event Subscription "egds-daevtdrop" (Scope "/subscriptions/***/resourceGroups/rg-integration-dev/providers/Microsoft.EventGrid/Domains/egd-phi-ledev"): eventgrid.EventSubscriptionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequest" Message="Invalid ARM Id."

  on dataprocessing\daevtdrop.tf line 52, in resource "azurerm_eventgrid_event_subscription" "egds-daevtdrop":
  52: resource "azurerm_eventgrid_event_subscription" "egds-daevtdrop" {```

Panic Output

None

Expected Behavior

Deploy the plan as expected and updated the resources

Actual Behavior

Errors: Invalid ARM Id

Steps to Reproduce

  1. terraform plan -out="dev.tfplan" -var-file="dev.tfvars"
  2. terraform apply "dev.tfplan"

Important Factoids

I could not get this to deploy due to the error, so I decided to create it manually through the Azure Portal. I then imported it into my local plan via terraform import. Nothing locally changed, and if you notice in the plan output, there is no change to the scope ID. However, when performing an apply, it errors with Invalid ARM Id.

References

devops-lucina commented 4 years ago

It turns out it was the function ID, not the scope. Working as planned. Apologies for the false alarm.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error πŸ€– πŸ™‰ , please reach out to my human friends πŸ‘‰ hashibot-feedback@hashicorp.com. Thanks!