From 55b37bcece971328691317c626c4bbdc34258794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maksymilian=20Bogu=C5=84?= Date: Mon, 29 Apr 2019 14:09:06 +0200 Subject: [PATCH] tags applied to stream analytics jobs --- azurerm/resource_arm_stream_analytics_job.go | 5 +++++ azurerm/resource_arm_stream_analytics_job_test.go | 8 +++++++- website/docs/r/stream_analytics_job.html.markdown | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_stream_analytics_job.go b/azurerm/resource_arm_stream_analytics_job.go index 93b386a4565b..2780e00760b0 100644 --- a/azurerm/resource_arm_stream_analytics_job.go +++ b/azurerm/resource_arm_stream_analytics_job.go @@ -104,6 +104,8 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "tags": tagsSchema(), }, } } @@ -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{ @@ -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() { @@ -264,6 +268,7 @@ func resourceArmStreamAnalyticsJobRead(d *schema.ResourceData, meta interface{}) d.Set("transformation_query", props.Query) } + flattenAndSetTags(d, resp.Tags) return nil } diff --git a/azurerm/resource_arm_stream_analytics_job_test.go b/azurerm/resource_arm_stream_analytics_job_test.go index 4a4e49d52185..81825e9117ca 100644 --- a/azurerm/resource_arm_stream_analytics_job_test.go +++ b/azurerm/resource_arm_stream_analytics_job_test.go @@ -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"), ), }, { @@ -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 = <