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

azurerm_monitor_diagnostic_setting - remove explicitly disable log in Update #20611

Merged

Conversation

teowa
Copy link
Contributor

@teowa teowa commented Feb 22, 2023

resolves #20554
A diagnostic setting must use either category_group or category in log(also enabled_log) block. The service API cannot accept diable a log with category_group and enable a log with category at the same time, see Azure/azure-rest-api-specs#22719

By test, we don't need to explicitly disable the logs in update.

TF_ACC=1 go test -v ./internal/services/monitor -parallel 20 -test.run=TestAccMonitorDiagnosticSetting_enabledLogs -timeout 1440m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccMonitorDiagnosticSetting_enabledLogs
=== PAUSE TestAccMonitorDiagnosticSetting_enabledLogs
=== CONT  TestAccMonitorDiagnosticSetting_enabledLogs
--- PASS: TestAccMonitorDiagnosticSetting_enabledLogs (507.91s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/monitor       509.859s

Some changes are to pass the acc test, relaetd to #20203

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @teowa. Could we also add test cases where an enabled_log with category_group is updated from 2 to 1 l enabled_logs and the same for category? It would be good to confirm that this works for logs being removed as well as added. Thanks!

@teowa
Copy link
Contributor Author

teowa commented Feb 23, 2023

Hi @catriona-m , thanks for reviewing.
Test cases are added:

  • TestAccMonitorDiagnosticSetting_enabledLogsMix: update across category and category_group
  • TestAccMonitorDiagnosticSetting_enabledLogsCategoryGroup: update category_group from 2 to 1
  • existing TestAccMonitorDiagnosticSetting_enabledLogs: update category from 2 to 1

@teowa
Copy link
Contributor Author

teowa commented Feb 23, 2023

TF_ACC=1 go test -v ./internal/services/monitor -parallel 20 -test.run=TestAccMonitorDiagnosticSetting_enabledLogs -timeout 1440m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccMonitorDiagnosticSetting_enabledLogsMix
=== PAUSE TestAccMonitorDiagnosticSetting_enabledLogsMix
=== RUN   TestAccMonitorDiagnosticSetting_enabledLogsCategoryGroup
=== PAUSE TestAccMonitorDiagnosticSetting_enabledLogsCategoryGroup
=== RUN   TestAccMonitorDiagnosticSetting_enabledLogs
=== PAUSE TestAccMonitorDiagnosticSetting_enabledLogs
=== CONT  TestAccMonitorDiagnosticSetting_enabledLogsMix
=== CONT  TestAccMonitorDiagnosticSetting_enabledLogs
=== CONT  TestAccMonitorDiagnosticSetting_enabledLogsCategoryGroup
--- PASS: TestAccMonitorDiagnosticSetting_enabledLogs (631.29s)
--- PASS: TestAccMonitorDiagnosticSetting_enabledLogsCategoryGroup (669.99s)
--- PASS: TestAccMonitorDiagnosticSetting_enabledLogsMix (761.90s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/monitor       761.943s

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failue:

------- Stdout: -------
=== RUN   TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace
=== PAUSE TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace
=== CONT  TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace
    testcase.go:110: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # azurerm_monitor_diagnostic_setting.test will be updated in-place
          ~ resource "azurerm_monitor_diagnostic_setting" "test" {
                id                             = "/subscriptions/*******/resourceGroups/acctestRG-230223172423818172/providers/Microsoft.KeyVault/vaults/acctest23022317242381817|acctest-DS-230223172423818172"
              + log_analytics_destination_type = "AzureDiagnostics"
                name                           = "acctest-DS-230223172423818172"
                # (2 unchanged attributes hidden)
        
        
                # (3 unchanged blocks hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace (335.14s)
FAIL

@grillba
Copy link

grillba commented Feb 23, 2023

Test failue:

------- Stdout: -------
=== RUN   TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace
=== PAUSE TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace
=== CONT  TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace
    testcase.go:110: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # azurerm_monitor_diagnostic_setting.test will be updated in-place
          ~ resource "azurerm_monitor_diagnostic_setting" "test" {
                id                             = "/subscriptions/*******/resourceGroups/acctestRG-230223172423818172/providers/Microsoft.KeyVault/vaults/acctest23022317242381817|acctest-DS-230223172423818172"
              + log_analytics_destination_type = "AzureDiagnostics"
                name                           = "acctest-DS-230223172423818172"
                # (2 unchanged attributes hidden)
        
        
                # (3 unchanged blocks hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace (335.14s)
FAIL

Refer #20203 for proposed resolution

@teowa
Copy link
Contributor Author

teowa commented Feb 24, 2023

The failed test should be fixed in PR #20203

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM 🪵

@katbyte katbyte merged commit 0c23dba into hashicorp:main Feb 24, 2023
@github-actions github-actions bot added this to the v3.46.0 milestone Feb 24, 2023
@github-actions
Copy link

github-actions bot commented Mar 6, 2023

This functionality has been released in v3.46.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!

@github-actions
Copy link

github-actions bot commented Apr 6, 2023

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants