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

bugfix: azurerm_stream_analytics_job resource does not set tags #3329

Merged
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
5 changes: 5 additions & 0 deletions azurerm/resource_arm_stream_analytics_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ func resourceArmStreamAnalyticsJob() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"tags": tagsSchema(),
},
}
}
Expand Down Expand Up @@ -140,6 +142,7 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte
outputErrorPolicy := d.Get("output_error_policy").(string)
streamingUnits := d.Get("streaming_units").(int)
transformationQuery := d.Get("transformation_query").(string)
tags := d.Get("tags").(map[string]interface{})

// needs to be defined inline for a Create but via a separate API for Update
transformation := streamanalytics.Transformation{
Expand All @@ -164,6 +167,7 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte
EventsOutOfOrderPolicy: streamanalytics.EventsOutOfOrderPolicy(eventsOutOfOrderPolicy),
OutputErrorPolicy: streamanalytics.OutputErrorPolicy(outputErrorPolicy),
},
Tags: expandTags(tags),
}

if d.IsNewResource() {
Expand Down Expand Up @@ -264,6 +268,7 @@ func resourceArmStreamAnalyticsJobRead(d *schema.ResourceData, meta interface{})
d.Set("transformation_query", props.Query)
}

flattenAndSetTags(d, resp.Tags)
return nil
}

Expand Down
8 changes: 7 additions & 1 deletion azurerm/resource_arm_stream_analytics_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func TestAccAzureRMStreamAnalyticsJob_basic(t *testing.T) {
Config: testAccAzureRMStreamAnalyticsJob_basic(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStreamAnalyticsJobExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.environment", "Test"),
),
},
{
Expand Down Expand Up @@ -162,7 +164,11 @@ resource "azurerm_stream_analytics_job" "test" {
events_out_of_order_max_delay_in_seconds = 50
events_out_of_order_policy = "Adjust"
output_error_policy = "Drop"
streaming_units = 3
streaming_units = 3

tags = {
environment = "Test"
}

transformation_query = <<QUERY
SELECT *
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/stream_analytics_job.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ resource "azurerm_stream_analytics_job" "example" {
output_error_policy = "Drop"
streaming_units = 3

tags = {
environment = "Example"
}

transformation_query = <<QUERY
SELECT *
INTO [YourOutputAlias]
Expand Down Expand Up @@ -65,6 +69,8 @@ The following arguments are supported:
* `streaming_units` - (Required) Specifies the number of streaming units that the streaming job uses. Supported values are `1`, `3`, `6` and multiples of `6` up to `120`.

* `transformation_query` - (Required) Specifies the query that will be run in the streaming job, [written in Stream Analytics Query Language (SAQL)](https://msdn.microsoft.com/library/azure/dn834998).

* `tags` - A mapping of tags assigned to the resource.

## Attributes Reference

Expand Down