-
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
new resource azurerm_monitor_action_rule_action_group
, azurerm_monitor_action_rule_suppression
#6563
Conversation
azurerm_alerts_management_action_rule
azurerm_monitor_action_rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @njuCZ,
In addition to the comments i've left inline i think it may be better to split this into three resources. It would simplify the code and also make it explicit what properties are required for each type. WDYT?
azurerm/internal/services/monitor/resource_arm_monitor_action_rule.go
Outdated
Show resolved
Hide resolved
func schemaActionRuleAlertContextCondtion() *schema.Schema { | ||
return schemaActionRuleCondtion( | ||
validation.StringInSlice([]string{ | ||
string(alertsmanagement.Equals), | ||
string(alertsmanagement.NotEquals), | ||
string(alertsmanagement.Contains), | ||
string(alertsmanagement.DoesNotContain), | ||
}, false), | ||
validation.StringIsNotEmpty, | ||
) | ||
} | ||
|
||
func schemaActionRuleAlertRuleIDCondtion() *schema.Schema { | ||
return schemaActionRuleCondtion( | ||
validation.StringInSlice([]string{ | ||
string(alertsmanagement.Equals), | ||
string(alertsmanagement.NotEquals), | ||
string(alertsmanagement.Contains), | ||
string(alertsmanagement.DoesNotContain), | ||
}, false), | ||
validation.StringIsNotEmpty, | ||
) | ||
} | ||
|
||
func schemaActionRuleDescriptionCondtion() *schema.Schema { | ||
return schemaActionRuleCondtion( | ||
validation.StringInSlice([]string{ | ||
string(alertsmanagement.Equals), | ||
string(alertsmanagement.NotEquals), | ||
string(alertsmanagement.Contains), | ||
string(alertsmanagement.DoesNotContain), | ||
}, false), | ||
validation.StringIsNotEmpty, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these all different when they all do the exact same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the rest api, there are different kinds of condition (something like filters), to explicitly show they are different kinds, I made individual functions for each condition.
As next comment suggests, unwrap these functions and make them inline, there will no this problem in revised version
azurerm/internal/services/monitor/resource_arm_monitor_action_rule.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/monitor/resource_arm_monitor_action_rule.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/monitor/tests/resource_arm_monitor_action_rule_test.go
Outdated
Show resolved
Hide resolved
azurerm_monitor_action_rule
azurerm_monitor_action_rule_action_group
, azurerm_monitor_action_rule_suppression
@katbyte thanks for your suggestion. I have splitted and made two resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @njuCZ, aside from a couple more small comments this is looking good!
azurerm/internal/services/monitor/monitor_action_rule_suppression_resource.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/monitor/tests/monitor_action_rule_action_group_resource_test.go
Outdated
Show resolved
Hide resolved
@katbyte thanks for the suggestions. I have refined the PR, Could you please have a check again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @njuCZ! LGTM now 👍
This has been released in version 2.13.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.13.0"
}
# ... other configuration ... |
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 👉 [email protected]. Thanks! |
fix #6564