Skip to content

Commit

Permalink
Make stream-analytics-job module optional (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoalonsoportillo committed Feb 8, 2023
1 parent 0c50b86 commit ea87661
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
15 changes: 7 additions & 8 deletions terraform/stream-analytics/stream-analytics-job/main.tf
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/stream_analytics_job

resource "azurerm_stream_analytics_job" "adl_asa" {
name = "asa-${var.basename}"
resource_group_name = var.rg_name
location = var.location

name = "asa-${var.basename}"
resource_group_name = var.rg_name
location = var.location
compatibility_level = var.compatibility_level
data_locale = var.data_locale
events_late_arrival_max_delay_in_seconds = var.events_late_arrival_max_delay_in_seconds
events_out_of_order_max_delay_in_seconds = var.events_out_of_order_max_delay_in_seconds
events_out_of_order_policy = var.events_out_of_order_policy
output_error_policy = var.output_error_policy
streaming_units = var.streaming_units

tags = var.tags

transformation_query = <<QUERY
transformation_query = <<QUERY
SELECT *
INTO [YourOutputAlias]
FROM [YourInputAlias]
QUERY
tags = var.tags

count = var.module_enabled ? 1 : 0
}
15 changes: 12 additions & 3 deletions terraform/stream-analytics/stream-analytics-job/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
output "id" {
value = azurerm_stream_analytics_job.adl_asa.id
value = (
length(azurerm_stream_analytics_job.adl_asa) > 0 ?
azurerm_stream_analytics_job.adl_asa[0].id : ""
)
}

output "name" {
value = azurerm_stream_analytics_job.adl_asa.name
value = (
length(azurerm_stream_analytics_job.adl_asa) > 0 ?
azurerm_stream_analytics_job.adl_asa[0].name : ""
)
}

output "resource_group_name" {
value = azurerm_stream_analytics_job.adl_asa.resource_group_name
value = (
length(azurerm_stream_analytics_job.adl_asa) > 0 ?
azurerm_stream_analytics_job.adl_asa[0].resource_group_name : ""
)
}
6 changes: 6 additions & 0 deletions terraform/stream-analytics/stream-analytics-job/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ variable "tags" {
description = "A mapping of tags which should be assigned to the deployed resource."
}

variable "module_enabled" {
type = bool
description = "Variable to enable or disable the module."
default = true
}

variable "compatibility_level" {
type = string
description = "Specifies the compatibility level for this job - which controls certain runtime behaviours of the streaming job."
Expand Down

0 comments on commit ea87661

Please sign in to comment.