Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eventgrid_event_subscription creates incomplete function endpoint id when used with function app endpoint #7419

Closed
Hjortsberg opened this issue Jun 20, 2020 · 3 comments
Labels

Comments

@Hjortsberg
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

TF.ver: 0.12.24, provider.ver: 2.14

Affected Resource(s)

  • azurerm_eventgrid_event_subscription_resource

Terraform Configuration Files

resource "azurerm_eventgrid_event_subscription" "main" {
  name  = var.event_subscription_name
  scope = "${data.azurerm_resources.domain.resources[local.indexdomain].id}/topics/my-domain-grid-topic"
  azure_function_endpoint {
    function_id = "${module.functionapp.id}/functions/NotificationEventHandler"
  }
}

Expected Behavior

A event subscription should be created for the function app with an AzureFunction endpoint type to the domain grid topic.

Actual Behavior

Terraform errors with following message:
eventgrid.EventSubscriptionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequest" Message="Invalid ARM Id.

After some poking around, it seems that the newly added function_endpoint function_id argument does not append "/functions/NotificationEventHandler" to the end of the function resource id, causing the error message upon terraform apply.
Adding that line, as in my hcl example snippet above fixes the problem.

References

@jrauschenbusch
Copy link
Contributor

Hey @Hjortsberg

this is not really a bug, but maybe the error message is not meaningful enough. The function_id attribute has to point to a function, not a function app. Due to the fact that a function app can host multiple functions and one is able to create it's own function (using an eventgrid binding) it's not guaranteed that it will be named NotificationEventHandler. Hence one has to manually concatenate the function id as long as there is no data source or resource for functions. (see #7354)

@Hjortsberg
Copy link
Contributor Author

Thanks for that clarification @jrauschenbusch.

As you say the error message together with the documentation did not make me wiser, but now I understand that this fault was on my side. I thought i tried to get the id by an exported resource field, but as you say, I used the wrong resource type. :)
I had misunderstood the innerworkings of function apps/functions.

I will close this issue now!
Have a nice day.

@ghost
Copy link

ghost commented Jul 21, 2020

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!

@hashicorp hashicorp locked and limited conversation to collaborators Jul 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants