Skip to content

Commit

Permalink
azurerm_stream_analytics_stream_input_eventhub_v2 - Add an example …
Browse files Browse the repository at this point in the history
…for MSI auth (#19679)
  • Loading branch information
alxy authored Jan 6, 2023
1 parent e31740a commit 3a632c6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 20 deletions.
1 change: 1 addition & 0 deletions examples/stream-analytics/msi-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ This example provisions a Stream Analytics job that uses [MSI authentication](ht
## Inputs

- `azurerm_stream_analytics_reference_input_blob`
- `azurerm_stream_analytics_stream_input_eventhub_v2`
78 changes: 58 additions & 20 deletions examples/stream-analytics/msi-auth/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,7 @@ resource "azurerm_resource_group" "example" {
location = var.location
}

resource "azurerm_storage_account" "example" {
name = "${var.prefix}examplestoracc"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_role_assignment" "example" {
scope = azurerm_storage_account.example.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = azurerm_stream_analytics_job.example.identity[0].principal_id
}

resource "azurerm_storage_container" "example" {
name = "${var.prefix}example"
storage_account_name = azurerm_storage_account.example.name
container_access_type = "private"
}

### Stream Analytics Job ###
resource "azurerm_stream_analytics_job" "example" {
name = "${var.prefix}-example-job"
resource_group_name = azurerm_resource_group.example.name
Expand Down Expand Up @@ -54,6 +35,27 @@ resource "azurerm_stream_analytics_job" "example" {
QUERY
}

### REFERENCE INPUT: Blob storage/ADLS Gen2 ###
resource "azurerm_storage_account" "example" {
name = "${var.prefix}examplestoracc"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_role_assignment" "example" {
scope = azurerm_storage_account.example.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = azurerm_stream_analytics_job.example.identity[0].principal_id
}

resource "azurerm_storage_container" "example" {
name = "${var.prefix}example"
storage_account_name = azurerm_storage_account.example.name
container_access_type = "private"
}

resource "azurerm_stream_analytics_reference_input_blob" "test" {
name = "${var.prefix}-blob-reference-input"
stream_analytics_job_name = azurerm_stream_analytics_job.example.name
Expand All @@ -70,3 +72,39 @@ resource "azurerm_stream_analytics_reference_input_blob" "test" {
encoding = "UTF8"
}
}

### STREAM INPUT: Event Hub ###
resource "azurerm_eventhub_namespace" "example" {
name = "${var.prefix}-example-namespace"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
sku = "Standard"
capacity = 1
}

resource "azurerm_eventhub" "example" {
name = "${var.prefix}-example-eventhub"
namespace_name = azurerm_eventhub_namespace.example.name
resource_group_name = azurerm_resource_group.example.name
partition_count = 2
message_retention = 1
}

resource "azurerm_role_assignment" "example_eventhub" {
scope = azurerm_eventhub.example.id
role_definition_name = "Azure Event Hubs Data receiver"
principal_id = azurerm_stream_analytics_job.example.identity[0].principal_id
}

resource "azurerm_stream_analytics_stream_input_eventhub_v2" "example" {
name = "${var.prefix}-eventhub-stream-input"
stream_analytics_job_id = azurerm_stream_analytics_job.example.id
eventhub_name = azurerm_eventhub.example.name
servicebus_namespace = azurerm_eventhub_namespace.example.name
authentication_mode = "Msi"

serialization {
type = "Json"
encoding = "UTF8"
}
}

0 comments on commit 3a632c6

Please sign in to comment.