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

Add database_routing to resource kusto eventhub #17525

Merged
merged 5 commits into from
Jul 11, 2022
Merged
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 @@ -141,6 +141,17 @@ func resourceKustoEventHubDataConnection() *pluginsdk.Resource {
string(kusto.EventHubDataFormatTXT),
}, false),
},

"database_routing_type": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: string(kusto.DatabaseRoutingSingle),
ValidateFunc: validation.StringInSlice([]string{
string(kusto.DatabaseRoutingSingle),
string(kusto.DatabaseRoutingMulti),
}, false),
},
},
}
}
Expand Down Expand Up @@ -180,6 +191,10 @@ func resourceKustoEventHubDataConnectionCreateUpdate(d *pluginsdk.ResourceData,
EventHubConnectionProperties: eventHubDataConnectionProperties,
}

if databaseRouting, ok := d.GetOk("database_routing_type"); ok {
dataConnection1.DatabaseRouting = kusto.DatabaseRouting(databaseRouting.(string))
}

future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ClusterName, id.DatabaseName, id.Name, dataConnection1)
if err != nil {
return fmt.Errorf("creating or updating %s: %+v", id, err)
Expand Down Expand Up @@ -229,6 +244,7 @@ func resourceKustoEventHubDataConnectionRead(d *pluginsdk.ResourceData, meta int
d.Set("table_name", props.TableName)
d.Set("mapping_rule_name", props.MappingRuleName)
d.Set("data_format", props.DataFormat)
d.Set("database_routing_type", props.DatabaseRouting)
d.Set("compression", props.Compression)
d.Set("event_system_properties", props.EventSystemProperties)
d.Set("identity_id", props.ManagedIdentityResourceID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ func TestAccKustoEventHubDataConnection_userAssignedIdentity(t *testing.T) {
})
}

func TestAccKustoEventHubDataConnection_databaseRoutingType(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kusto_eventhub_data_connection", "test")
r := KustoEventHubDataConnectionResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.databaseRoutingType(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("database_routing_type").HasValue("Multi"),
),
},
data.ImportStep(),
})
}

func (KustoEventHubDataConnectionResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.DataConnectionID(state.ID)
if err != nil {
Expand Down Expand Up @@ -257,6 +273,24 @@ resource "azurerm_kusto_eventhub_data_connection" "test" {
`, r.template(data), data.RandomInteger)
}

func (r KustoEventHubDataConnectionResource) databaseRoutingType(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_kusto_eventhub_data_connection" "test" {
name = "acctestkedc-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
cluster_name = azurerm_kusto_cluster.test.name
database_name = azurerm_kusto_database.test.name
eventhub_id = azurerm_eventhub.test.id
consumer_group = azurerm_eventhub_consumer_group.test.name
mapping_rule_name = "Json_Mapping"
data_format = "MULTIJSON"
database_routing_type = "Multi"
}
`, r.template(data), data.RandomInteger)
}

func (KustoEventHubDataConnectionResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ The following arguments are supported:

* `database_name` - (Required) Specifies the name of the Kusto Database this data connection will be added to. Changing this forces a new resource to be created.


* `eventhub_id` - (Required) Specifies the resource id of the EventHub this data connection will use for ingestion. Changing this forces a new resource to be created.

* `event_system_properties` - (Optional) Specifies a list of system properties for the Event Hub.
Expand All @@ -107,6 +106,8 @@ The following arguments are supported:

* `data_format` - (Optional) Specifies the data format of the EventHub messages. Allowed values: `APACHEAVRO`, `AVRO`, `CSV`, `JSON`, `MULTIJSON`, `ORC`, `PARQUET`, `PSV`, `RAW`, `SCSV`, `SINGLEJSON`, `SOHSV`, `TSVE`, `TSV`, `TXT`, and `W3CLOGFILE`.

* `database_routing_type` - (Optional) Indication for database routing information from the data connection, by default only database routing information is allowed. Allowed values: `Single`, `Multi`.

## Attributes Reference

The following attributes are exported:
Expand Down