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

Adding user defined properties to service bus correlation filters #8645

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ func resourceArmServiceBusSubscriptionRule() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"properties": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
Expand Down Expand Up @@ -295,8 +302,9 @@ func expandAzureRmServiceBusCorrelationFilter(d *schema.ResourceData) (*serviceb
replyToSessionID := config["reply_to_session_id"].(string)
sessionID := config["session_id"].(string)
to := config["to"].(string)
properties := utils.ExpandMapStringPtrString(config["properties"].(map[string]interface{}))

if contentType == "" && correlationID == "" && label == "" && messageID == "" && replyTo == "" && replyToSessionID == "" && sessionID == "" && to == "" {
if contentType == "" && correlationID == "" && label == "" && messageID == "" && replyTo == "" && replyToSessionID == "" && sessionID == "" && to == "" && len(properties) == 0 {
return nil, fmt.Errorf("At least one property must be set in the `correlation_filter` block")
}

Expand Down Expand Up @@ -334,6 +342,10 @@ func expandAzureRmServiceBusCorrelationFilter(d *schema.ResourceData) (*serviceb
correlationFilter.ContentType = utils.String(contentType)
}

if len(properties) > 0 {
correlationFilter.Properties = properties
}

return &correlationFilter, nil
}

Expand Down Expand Up @@ -376,5 +388,9 @@ func flattenAzureRmServiceBusCorrelationFilter(input *servicebus.CorrelationFilt
filter["content_type"] = *input.ContentType
}

if input.Properties != nil {
filter["properties"] = utils.FlattenMapStringPtrString(input.Properties)
}

return []interface{}{filter}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ resource "azurerm_servicebus_subscription_rule" "test" {
session_id = "test_session_id"
reply_to_session_id = "test_reply_to_session_id"
content_type = "test_content_type"
properties = {
test_key = "test_value"
}
}
}
`, template, data.RandomInteger)
Expand All @@ -322,6 +325,9 @@ resource "azurerm_servicebus_subscription_rule" "test" {
correlation_filter {
correlation_id = "test_correlation_id"
message_id = "test_message_id"
properties = {
test_key = "test_value"
}
}
}
`, template, data.RandomInteger)
Expand All @@ -344,6 +350,9 @@ resource "azurerm_servicebus_subscription_rule" "test" {
correlation_id = "test_correlation_id"
message_id = "test_message_id_updated"
reply_to = "test_reply_to_added"
properties = {
test_key = "test_value_updated"
}
}
}
`, template, data.RandomInteger)
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/servicebus_subscription_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ resource "azurerm_servicebus_subscription_rule" "example" {
correlation_filter {
correlation_id = "high"
label = "red"
properties = {
customProperty = "value"
}
}
}
```
Expand Down Expand Up @@ -146,6 +149,8 @@ The following arguments are supported:

* `to` - (Optional) Address to send to.

* `properties` - (Optional) A list of user defined properties to be included in the filter. Specified as a map of name/value pairs.

~> **NOTE:** When creating a subscription rule of type `CorrelationFilter` at least one property must be set in the `correlation_filter` block.


Expand Down