-
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: resource_arm_servicebus_subscription_rule
#1124
Conversation
azurerm_servicebus_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.
hey @jpovey
Thanks for this PR - I've taken a look through and left some comments in-line, but this is off to a good start. If we can clean up the comments then we should be good to run the tests :)
Thanks!
} | ||
|
||
if properties.CorrelationFilter != nil { | ||
if err := d.Set("correlation_filter", flattenAzureRmServiceBusCorrelationFilter(properties.CorrelationFilter)); err != nil { |
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.
can we update this to always set the correlation_filter
field - but only to return items if properties.CorrelationFilter
isn't nil? e.g.
if err := d.Set("correlation_filter", flattenAzureRmServiceBusCorrelationFilter(properties.CorrelationFilter)); err != nil {
return fmt.Errorf("...")
}
func flattenAzureRmServiceBusCorrelationFilter(input *servicebus.CorrelationFilter) []interface{} {
if input == nil {
return []interface{}{}
}
output := make(map[string]interface{}, 0)
// assignment
return []interface{}{output}
}
|
||
"correlation_filter": { | ||
Type: schema.TypeList, | ||
Optional: true, |
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.
from what I can see from the schema below, there can only be one of these, can we add MaxItems: 1
to this?
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.
we can also add ConflictsWith: []string{"sql_filter"}
here which should handle only one of them being specified
} | ||
|
||
rule := servicebus.Rule{ | ||
Ruleproperties: &ruleProperties, |
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.
minor: we can actually just inline these two objects e.g.
rule := servicebus.Rule{
Ruleproperties: &servicebus.Ruleproperties{
FilterType: servicebus.FilterType(filterType),
// ..
},
}
azurerm/provider.go
Outdated
@@ -190,6 +190,7 @@ func Provider() terraform.ResourceProvider { | |||
"azurerm_servicebus_namespace": resourceArmServiceBusNamespace(), | |||
"azurerm_servicebus_queue": resourceArmServiceBusQueue(), | |||
"azurerm_servicebus_subscription": resourceArmServiceBusSubscription(), | |||
"azurerm_servicebus_rule": resourceArmServiceBusRule(), |
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.
from what I can tell, these are known as ServiceBus Subscription Rules - as such would it make sense for this to be azurerm_servicebus_subscription_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 Tom
I did consider this but in both the Service Bus documentation and in the go SDK they are known simply as 'rules' and i wanted to keep consistency with this terraform module.
https://docs.microsoft.com/en-us/rest/api/servicebus/rules/createorupdate
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.
so the Documentation and Go SDK are actually both generated from the same Swagger file - so the Azure Portal tends to be a more reliable source of truth. Given we've already got support for ServiceBus Topic Authorization Rules, I think this would be best as Subscription Rule
(given it's scoped to that level) in-case a Namespace-wide rule is added in the future - WDYT?
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.
Ok, sounds good to me. Will get this sorted and updated soon
DiffSuppressFunc: ignoreCaseDiffSuppressFunc, | ||
}, | ||
|
||
"location": deprecatedLocationSchema(), |
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.
I think we can remove this, since it's not being used?
topic_name = "${azurerm_servicebus_topic.test.name}" | ||
subscription_name = "${azurerm_servicebus_subscription.test.name}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
%s |
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.
can we duplicate this into each test and make the spacing consistent here?
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.
Is there any reason to duplicate the topic, subscription and resource group as these will be the same for each test?
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.
we tend to point people towards the test cases as examples of how to use features when people ask for end-to-end examples; the main goal here is to make them - so the aim here is to make them as readable as possible; I think it's fine to duplicate the topic, subscription and resource group - but can we add the entire resource definition for the azurerm_servicebus_subscription_rule
into each test? e.g.
resource "azurerm_servicebus_subscription_rule" "test" {
# ...
}
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.
Ok sure, i get what you mean
Create a ServiceBus Rule. | ||
--- | ||
|
||
# azurerm\_servicebus\_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.
minor we can remove the backslashes here
|
||
* `sql_filter` - (Optional) Represents a filter written in SQL language-based syntax that to be evaluated against a BrokeredMessage. Must be set when `filter_type` is set to `SqlFilter`. | ||
|
||
* `correlation_filter` - (Optional) A `correlation_filter` block as documented below to be evaluated against a BrokeredMessage. Must be set when `filter_type` is set to `CorrelationFilter`. |
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.
Can we change Must be set
-> Required
for consistency purposes?
|
||
* `filter_type` - (Required) Type of filter to be applied to a BrokeredMessage. Possible values are `SqlFilter` and `CorrelationFilter`. | ||
|
||
* `sql_filter` - (Optional) Represents a filter written in SQL language-based syntax that to be evaluated against a BrokeredMessage. Must be set when `filter_type` is set to `SqlFilter`. |
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.
Can we change Must be set
-> Required
for consistency purposes?
correlationFilter.ContentType = &contentType | ||
} | ||
|
||
return &correlationFilter |
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.
based on this comment: https://github.com/terraform-providers/terraform-provider-azurerm/pull/1124/files#diff-5ae250cddcb7acd8b53f87d1465954bfR168 - is it worth raising an error if no properties have been set?
Morning Tom, Jon |
…om being set at the same time
…set in correlation block
I have updated the pull request with all the changes above apart from changing the modules name to Let me know what you think Cheers |
…zure portal and dependency on service_bus_subscription
… more than 50 chars
All changes have been made including change the name of the module to Let me know if there is anything else which needs to be done and i will try and get on it over the weekend cheers |
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.
hey @jpovey
Thanks for pushing those updates - I've taken a look through and whilst this needs some minor refactoring to make it consistent with the other resources (which I'll open a PR for) - this otherwise LGTM 👍
Thanks!
Awesome, that's great news. Thanks for the quick review process. |
azurerm_servicebus_rule
resource_arm_servicebus_subscription_rule
resource_arm_servicebus_subscription_rule
resource_arm_servicebus_subscription_rule
I could not find this in the terraform doc for azure. Could you please update the doc too? |
Are these the docs you're looking for @vanthoainguyen ? |
These are, thanks 🤦♂️ |
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! |
Add AzureRM Servicebus rule module, tests and documentation. Applies to feature request #145