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

Destroy azurerm_network_watcher_flow_log fails if traffic_analytics is not enabled #6913

Closed
markhoiland opened this issue May 13, 2020 · 2 comments · Fixed by #7154
Closed

Comments

@markhoiland
Copy link

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 v0.12.24

  • provider.azurerm v2.5.0

Affected Resource(s)

  • azurerm_network_watcher_flow_log

Terraform Configuration Files

resource "azurerm_network_watcher_flow_log" "flow-log-main" {
count = length(var.region)

network_watcher_name = azurerm_network_watcher.my-nw[count.index].name
resource_group_name = data.azurerm_resource_group.my-rg.name
network_security_group_id = element(matchkeys(azurerm_network_security_group.my-nsg..id, azurerm_network_security_group.my-nsg..location, var.region), count.index)
storage_account_id = azurerm_storage_account.nsg-storage[count.index].id
enabled = true
version = 2

retention_policy {
enabled = true
days = 30

}
}

Debug Output

Error: Error disabling Flow Log Configuration for target "/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/test-rg/providers/Microsoft.Network/networkSecurityGroups/my-main-nsg" (Network Watcher "NetworkWatcher_eastasia" / Resource Group "test-rg"): network.WatchersClient#SetFlowLogConfiguration: Invalid input: autorest/validation: validation failed: parameter=parameters.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration constraint=Null value=(*network.TrafficAnalyticsConfigurationProperties)(nil) details: value cannot be null; required parameter

Expected Behavior

All NSG resources should be destroyed, including the NSG Flog Log configurations, even if Traffic Analytics is in a disabled state as configured by the Terraform code.

Actual Behavior

When destroying deployed TF resources, TF is trying to disable NSG Flow logs and expecting “Traffic Analytics” section in enabled mode. If "Traffic Analytics" is disabled, the destroy errors out and will not destroy the NSG resources.

Steps to Reproduce

  1. terraform apply
  2. terraform destroy

Important Factoids

When the following code to enable Traffic Analytics for the NSG Flow Logs is included, the destroy command works without issue.

traffic_analytics {
enabled = true
workspace_id = element(azurerm_log_analytics_workspace.my-workspace..workspace_id, count.index)
workspace_region = element(azurerm_log_analytics_workspace.my-workspace.
.location, count.index)
workspace_resource_id = element(azurerm_log_analytics_workspace.my-workspace.*.id, count.index)
// interval_in_minutes = 60
}
}

References

@ghost
Copy link

ghost commented Jun 19, 2020

This has been released in version 2.15.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.15.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Jul 17, 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 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants