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

r/azurerm_application_insights - provider feature disable_generated_rule isn't working #16124

Closed
t3mi opened this issue Mar 29, 2022 · 7 comments · Fixed by #16170
Closed

r/azurerm_application_insights - provider feature disable_generated_rule isn't working #16124

t3mi opened this issue Mar 29, 2022 · 7 comments · Fixed by #16170
Labels
Milestone

Comments

@t3mi
Copy link
Contributor

t3mi commented Mar 29, 2022

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

Terraform v1.0.11
on windows_amd64

  • provider registry.terraform.io/hashicorp/azurerm v3.0.2

Affected Resource(s)

  • azurerm_application_insights

Terraform Configuration Files

provider "azurerm" {
  features {
    application_insights {
      disable_generated_rule = true
    }
  }
}

resource "azurerm_resource_group" "example" {
  name     = "tf-test"
  location = "West Europe"
}

resource "azurerm_application_insights" "example" {
  name                = "tf-test-appinsights"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  application_type    = "web"
}

Debug Output

Panic Output

Expected Behaviour

No errors, application insights resource provisioned without default rules.

Actual Behaviour

azurerm_application_insights.example: Still creating... [58m24s elapsed]
azurerm_application_insights.example: Still creating... [58m34s elapsed]
azurerm_application_insights.example: Still creating... [58m44s elapsed]
azurerm_application_insights.example: Still creating... [58m54s elapsed]
azurerm_application_insights.example: Still creating... [59m4s elapsed]
azurerm_application_insights.example: Still creating... [59m14s elapsed]
azurerm_application_insights.example: Still creating... [59m24s elapsed]
azurerm_application_insights.example: Still creating... [59m34s elapsed]
azurerm_application_insights.example: Still creating... [59m44s elapsed]
azurerm_application_insights.example: Still creating... [59m54s elapsed]
azurerm_application_insights.example: Still creating... [1h0m4s elapsed]
azurerm_application_insights.example: Still creating... [1h0m14s elapsed]
╷
│ Error: making Read request for Action Group: (Name "Application Insights Smart Detection" / Resource Group "tf-test"): insights.ActionGroupsClient#Get: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded
│
│   with azurerm_application_insights.example,
│   on main.tf line 14, in resource "azurerm_application_insights" "example":14: resource "azurerm_application_insights" "example" {
│

Steps to Reproduce

  1. terraform apply
  2. Wait default timeout (1h) to see the errors.

Important Factoids

References

@katbyte
Copy link
Collaborator

katbyte commented Mar 30, 2022

(introduced by pr #15892)

@sebader
Copy link
Contributor

sebader commented Mar 30, 2022

Ran into the same. It actually looks like the AppInsights resource gets properly created but TF doesn't realize that

@mbfrahry
Copy link
Member

Hey @t3mi and @sebader, the change implemented in #15892 tries to disable both the Rule and Action Group that are created by Azure when spinning up an Application Insight resource (See #10563 for more context). Sometimes, that Action Group takes forever to spin up so we end up hitting our own create timeout just waiting to disable that Action Group.

With that said, I believe just disabling the Rule should be enough as the Action Group is just acting on that Azure created rule and nothing else. Is that true? And if so, would it make sense to just disable the Rule and leave the Action Group alone?

@github-actions
Copy link

github-actions bot commented Apr 8, 2022

This functionality has been released in v3.1.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@sebader
Copy link
Contributor

sebader commented Apr 11, 2022

@mbfrahry I just tested this in 3.1: So the deployment works now and indeed, the rules are not created anymore, the action group gets created, still. This still doesn't solve the actual problem with the new 3.x version: the default behavior of prevent_deletion_if_contains_resources = true. Resource group deletion will fail since that action group is automatically created and not deleted when deleting appinsights

@tombuildsstuff
Copy link
Contributor

@sebader

So the deployment works now and indeed, the rules are not created anymore, the action group gets created, still.

IIRC (from chatting with @mbfrahry about this) when deleting the Action Group it gets automatically recreated by the API (regardless of how many times you delete it/retry) - so I believe that maybe a service limitation at this time.

Resource group deletion will fail since that action group is automatically created and not deleted when deleting appinsights

That's by design with this new feature, you can disable that behaviour using the feature-flag you've described above.


Since this is now a service issue, I'd recommend filing an issue with the Service Team so that they can take a look into this - since (due to the auto-recreation issue above) this doesn't appear to be something we can fix in Terraform at this time unfortunately.

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
6 participants