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_activity_log_alert: support properties.recommendationType #7458

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Jun 24, 2020

azurerm_monitor_activity_log_alert: support properties.recommendationType for recommendation alerts.

There is no document for this field, but via inspecting the API flow in portal, the mode is like below:

        "condition": {
            "allOf": [
                {
                    "field": "category",
                    "equals": "Recommendation",
                    "containsAny": null,
                    "odata.type": null
                },
                {
                    "field": "operationName",
                    "equals": "Microsoft.Advisor/recommendations/available/action",
                    "containsAny": null,
                    "odata.type": null
                },
                {
                    "field": "properties.recommendationType",
                    "equals": "2b5eac39-9f50-4d8d-bc9b-1e1e07c5c37e",
                    "containsAny": null,
                    "odata.type": null
                }
            ],
            "odata.type": null
        },

The id can be got from azurerm_advisor_recommendation data source or by other means.

(fix: #7300)

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 for the PR @magodo, overall looks good but we have a failing test:

 TestAccAzureRMMonitorActivityLogAlert_basicAndCompleteUpdate: testing.go:640: Step 1 error: errors during apply:
        
        Error: Error creating or updating activity log alert "acctestActivityLogAlert-200624031619256159" (resource group "acctestRG-200624031619256159"): insights.ActivityLogAlertsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ConditionValueInvalid" Message="Invalid value user@example.com for condition caller"

@ghost ghost added size/M and removed size/XS labels Jun 24, 2020
@magodo
Copy link
Collaborator Author

magodo commented Jun 24, 2020

@katbyte The test also failed in master branch. The cause is that Recommendation category event now has its own fields: properties.RecommendationType, properties.RecommendationCategory and properties.RecommendationImpact.

I complement those into the schema, also fixed the test.

Test Result

💤 via 🦉 v1.14.4 make testacc TEST=./azurerm/internal/services/monitor/tests TESTARGS='-run TestAccAzureRMMonitorActivityLogAlert_'        
                                                                                                                                                                                     
==> Checking that code complies with gofmt requirements...                                                                                                                           
==> Checking that Custom Timeouts are used...                                                                                                                                        
==> Checking that acceptance test packages are used...                                                                                                                               
TF_ACC=1 go test ./azurerm/internal/services/monitor/tests -v -run TestAccAzureRMMonitorActivityLogAlert_ -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccAzureRMMonitorActivityLogAlert_basic                                     
=== PAUSE TestAccAzureRMMonitorActivityLogAlert_basic                                     
=== RUN   TestAccAzureRMMonitorActivityLogAlert_requiresImport                                                                                                                       
=== PAUSE TestAccAzureRMMonitorActivityLogAlert_requiresImport                            
=== RUN   TestAccAzureRMMonitorActivityLogAlert_singleResource                                                                                                                       
=== PAUSE TestAccAzureRMMonitorActivityLogAlert_singleResource                      
=== RUN   TestAccAzureRMMonitorActivityLogAlert_complete
=== PAUSE TestAccAzureRMMonitorActivityLogAlert_complete                                                                                                                             
=== RUN   TestAccAzureRMMonitorActivityLogAlert_basicAndCompleteUpdate                                                                                                               
=== PAUSE TestAccAzureRMMonitorActivityLogAlert_basicAndCompleteUpdate                                                                                                               
=== CONT  TestAccAzureRMMonitorActivityLogAlert_basic                                  
=== CONT  TestAccAzureRMMonitorActivityLogAlert_basicAndCompleteUpdate                                                                                                               
=== CONT  TestAccAzureRMMonitorActivityLogAlert_singleResource                                                                                                                       
=== CONT  TestAccAzureRMMonitorActivityLogAlert_complete                                  
=== CONT  TestAccAzureRMMonitorActivityLogAlert_requiresImport                                                                                                                       
--- PASS: TestAccAzureRMMonitorActivityLogAlert_basic (110.98s)                                                                                                                      
--- PASS: TestAccAzureRMMonitorActivityLogAlert_requiresImport (121.56s)                                                                                                             
--- PASS: TestAccAzureRMMonitorActivityLogAlert_basicAndCompleteUpdate (215.16s)                                                                                                     
--- PASS: TestAccAzureRMMonitorActivityLogAlert_singleResource (237.28s)                                                                                                             
--- PASS: TestAccAzureRMMonitorActivityLogAlert_complete (238.26s)                        
PASS                                                                                      
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/monitor/tests       238.295s

Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for this @magodo

@tombuildsstuff tombuildsstuff dismissed katbyte’s stale review June 25, 2020 08:10

dismissing since changes have been pushed

@tombuildsstuff tombuildsstuff merged commit 16c702f into hashicorp:master Jun 25, 2020
@tombuildsstuff tombuildsstuff added this to the v2.16.0 milestone Jun 25, 2020
tombuildsstuff added a commit that referenced this pull request Jun 25, 2020
@ghost
Copy link

ghost commented Jun 25, 2020

This has been released in version 2.16.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.16.0"
}
# ... other configuration ...

jrauschenbusch pushed a commit to jrauschenbusch/terraform-provider-azurerm that referenced this pull request Jun 29, 2020
@ghost
Copy link

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

Successfully merging this pull request may close these issues.

azurerm_monitor_activity_log_alert recommendationType property
3 participants