-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_monitor_diagnostic_setting in state file there is always empty string of "log_analytics_destination_type": "", despite the value is defined in .tf #8131
Comments
FYI |
This is from DEBUG log:
Also from DEBUG log I see API operations executed on "terraform apply" as following: 1, PUT operations returns the correct response "logAnalyticsDestinationType":"Dedicated" It uses this specific microsoft azure api: |
Hey @eissko Thank you for submitting this 👍 As you have noticed, there is an upstream issue about the confusing In regards to your specific issue, you can simply leave |
@magodo Yes there is upstream issue. But it has been open again when I mentioned it in my issue. Before, it had been closed by bot. I assumed nobody were taking care of it. And unfortunately, I can't leave it empty. Hence:
thanks Peter |
@eissko Have you tried to leave |
@magodo yes I tried to leave it empty. as you see above or below I got an error: Error: expected log_analytics_destination_type to be one of [Dedicated AzureDiagnostics], got |
@eissko, I mean just to comment out that attribute at all (rather than setting it an empty string). I have verified it locally. |
@magodo I can try that but still for some resource we need to set it as "Dedicated" and for some "AzureDiagnostics". The clean solution would fix the bug in API anyway. |
The argument Though some resources support It is, in fact, supporting This CLI document can be used to confirm it too. The command only takes the flag |
even if the destination is event hub and the property is not present at all, then also it is showing a plan change for log_analytics_destination_type from "AzureDiagnostics" to "Null". Hence needed some fix here |
Updating log_analytics_destination_type to "AzureDiagnostics" avoids plan change, however if there is any update to azurerm_monitor_diagnostic_setting, apply fails with following error meaning there is no workaround for this problem! Error: |
Also happens with Recovery Services Vaults. |
Came across this with a Synapse SQL Pool. I checked and onfirmed the Rest API rturns
|
I have this issue on APIM resources where
Editing the state to remove this field, setting it to null or not at all does not change anything. Resource can be created but never updated. EDIT: |
How long will it take to fix this? Any plans on this? |
Hello guys, |
Hi, I am facing the same issue with one of the key vaults (strangely enough it just one out of 15). The state is not updated with 'AzureDiagnostics' value; portal also shows as value as 'null'. TF reports that it updates the resource. |
Facing the same issue with MSSQL server and DB. It updates |
The same issue with azurerm > 3.38 version
if you apply the changes and then make a terraform plan not seeing the issue with azurerm 3.38 |
same on version 3.42.0 which is the latest version as of now.
|
It seems to me that hashitop has hit the nail on the head. The resource azurerm_monitor_diagnostic_setting applies to many different underlying resources and the responses can differ according to the underlying resource. For example when pointed at an AzureFirewall the API does return "logAnalyticsDestinationType": "AzureDiagnostics" but against an automation account and bastion I get back "logAnalyticsDestinationType": null. Feel free to try your own cases here try it To quote again the API documentation "properties.logAnalyticsDestinationType = A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: Possible values are: Dedicated and null (null is default.)" I assume the logic is currently that when set to AzureDiagnostics we send null via the API but we record AzureDiagnostics in the state. Hence the drift when we get null back, except in cases such as the firewall when we get AzureDiagnostics back. Conversely for the firewall I'd guess when we sent null we'd get AzureDiagnostics back and see a change, which probably led to the original Terraform change in this area, but I can't test this easily at this time. I'd suggest we allow three states; not set/null => we send null, AzureDiagnostics we send AzureDiagnostics, Dedicated we send Dedicated. This ought to cater for any case. I haven't looked at the code to check my assumption. If get time I'll see if I can play with the code. |
I had a play. By making the attribute optional and allowing it to be set to null, it allows the appropriate setting for a resource so there is no drift and no need for lifecycle ignore. You need to work out what to set it too but a plan after an apply will tell you if you got it wrong (or you can see what the API sends back). It isn't ideal but it does give the greatest flexibility and ought to be good for all resource types. With the change in place then I need to set as follows for my three cases: automation account: log_analytics_destination_type = null Up to now for the first two I've had to add a lifecycle ignore. If people think this is ok I can do a PR once I work out the test cases and a suitable documentation update. |
Seems like this issue has been fixed as a Bug Fix in the latest Azurerm version 3.45.0, this update fixed my issue after running one apply. |
@WouterVan looks like it. Here #20203 Maybe, we can close this issue too. But I created it 3 years ago. And I am not able to verify it now. |
I was able to verify that no change is detected after upgrading to 3.45.0. |
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. |
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.12.29
Affected Resource(s)
azurerm_monitor_diagnostic_setting
Terraform Configuration Files
Debug Output
2020/08/14 21:22:58 [WARN] Provider "registry.terraform.io/-/azurerm" produced an unexpected new value for azurerm_monitor_diagnostic_setting.diag, but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations: - .eventhub_name: was null, but now cty.StringVal("") **- .log_analytics_destination_type: was cty.StringVal("Dedicated"), but now cty.StringVal("")** - .eventhub_authorization_rule_id: was null, but now cty.StringVal("")
Panic Output
none
Expected Behavior
In the tfstate must be stored proper value as defined in terraform configuration. Hence this is expect value in terraform state file "log_analytics_destination_type": "Dedicated".
Actual Behavior
Actual behavior is that the value of attribute "log_analytics_destination_type" is always empty string "" regardless what is defined in the terraform code. Which leads every terraform plan showing CHANGE every time it is run.
Steps to Reproduce
Take terraform configuration provided above. Attach proper secrets as defined in configuration :
secrets = {
subscription_id = ""
tenant_id = ""
client_id = ""
client_secret = ""
}
1
terraform init
2
terraform apply
3 - manual step - check the terraform state where you are gonna find the empty string for "log_analytics_destination_type": ""
4 -
terraform plan
- plan will result in the 1 change of attribute "log_analytics_destination_type": "" - which is infinite processThe text was updated successfully, but these errors were encountered: