diff --git a/CHANGELOG.md b/CHANGELOG.md index 78d77832716e5..fcd3c6564f4a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ FEATURES: BUG FIXES: +* `azurerm_application_insights` - fixing a bug where `application_type` was set to `other` [GH-1563] +* `azurerm_servicebus_subscription` - only sending `correlation_filter` values if they're set [GH-1565] * `azurerm_traffic_manager_endpoint` - working around a bug in the API by setting `target` to nil when a `target_resource_id` is specified [GH-1546] ## 1.9.0 (July 11, 2018) diff --git a/azurerm/import_arm_application_insights_test.go b/azurerm/import_arm_application_insights_test.go index 657dc8ee420c6..5f5ab02965da9 100644 --- a/azurerm/import_arm_application_insights_test.go +++ b/azurerm/import_arm_application_insights_test.go @@ -11,7 +11,7 @@ func TestAccAzureRMApplicationInsights_importBasicWeb(t *testing.T) { resourceName := "azurerm_application_insights.test" ri := acctest.RandInt() - config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation()) + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -35,7 +35,7 @@ func TestAccAzureRMApplicationInsights_importBasicOther(t *testing.T) { resourceName := "azurerm_application_insights.test" ri := acctest.RandInt() - config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation()) + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/azurerm/resource_arm_application_insights.go b/azurerm/resource_arm_application_insights.go index 54abebb20e5e7..7bc184f4ef705 100644 --- a/azurerm/resource_arm_application_insights.go +++ b/azurerm/resource_arm_application_insights.go @@ -38,8 +38,12 @@ func resourceArmApplicationInsights() *schema.Resource { ForceNew: true, DiffSuppressFunc: ignoreCaseDiffSuppressFunc, ValidateFunc: validation.StringInSlice([]string{ - string(insights.Web), - string(insights.Other), + "web", + "other", + "java", + "phone", + "store", + "ios", }, true), }, diff --git a/azurerm/resource_arm_application_insights_test.go b/azurerm/resource_arm_application_insights_test.go index f627d025c5ae9..c5e5a2523d495 100644 --- a/azurerm/resource_arm_application_insights_test.go +++ b/azurerm/resource_arm_application_insights_test.go @@ -13,7 +13,7 @@ import ( func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) { ri := acctest.RandInt() - config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation()) + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -24,6 +24,28 @@ func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"), + resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "web"), + ), + }, + }, + }) +} + +func TestAccAzureRMApplicationInsights_basicJava(t *testing.T) { + + ri := acctest.RandInt() + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "java") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMApplicationInsightsDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"), + resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "java"), ), }, }, @@ -33,7 +55,7 @@ func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) { func TestAccAzureRMApplicationInsights_basicOther(t *testing.T) { ri := acctest.RandInt() - config := testAccAzureRMApplicationInsights_basicOther(ri, testLocation()) + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "other") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -44,6 +66,70 @@ func TestAccAzureRMApplicationInsights_basicOther(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"), + resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "other"), + ), + }, + }, + }) +} + +func TestAccAzureRMApplicationInsights_basicPhone(t *testing.T) { + + ri := acctest.RandInt() + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "phone") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMApplicationInsightsDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"), + resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "phone"), + ), + }, + }, + }) +} + +func TestAccAzureRMApplicationInsights_basicStore(t *testing.T) { + + ri := acctest.RandInt() + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "store") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMApplicationInsightsDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"), + resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "store"), + ), + }, + }, + }) +} + +func TestAccAzureRMApplicationInsights_basiciOS(t *testing.T) { + + ri := acctest.RandInt() + config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "ios") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMApplicationInsightsDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"), + resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "ios"), ), }, }, @@ -106,23 +192,7 @@ func testCheckAzureRMApplicationInsightsExists(name string) resource.TestCheckFu } } -func testAccAzureRMApplicationInsights_basicWeb(rInt int, location string) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_application_insights" "test" { - name = "acctestappinsights-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - application_type = "web" -} -`, rInt, location, rInt) -} - -func testAccAzureRMApplicationInsights_basicOther(rInt int, location string) string { +func testAccAzureRMApplicationInsights_basic(rInt int, location string, applicationType string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -133,7 +203,7 @@ resource "azurerm_application_insights" "test" { name = "acctestappinsights-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - application_type = "other" + application_type = "%s" } -`, rInt, location, rInt) +`, rInt, location, rInt, applicationType) } diff --git a/azurerm/resource_arm_servicebus_subscription_rule.go b/azurerm/resource_arm_servicebus_subscription_rule.go index 0a37667b2b59c..f8f3f1e3c63b2 100644 --- a/azurerm/resource_arm_servicebus_subscription_rule.go +++ b/azurerm/resource_arm_servicebus_subscription_rule.go @@ -268,15 +268,38 @@ func expandAzureRmServiceBusCorrelationFilter(d *schema.ResourceData) (*serviceb return nil, fmt.Errorf("At least one property must be set in the `correlation_filter` block") } - correlationFilter := servicebus.CorrelationFilter{ - CorrelationID: utils.String(correlationID), - MessageID: utils.String(messageID), - To: utils.String(to), - ReplyTo: utils.String(replyTo), - Label: utils.String(label), - SessionID: utils.String(sessionID), - ReplyToSessionID: utils.String(replyToSessionID), - ContentType: utils.String(contentType), + correlationFilter := servicebus.CorrelationFilter{} + + if correlationID != "" { + correlationFilter.CorrelationID = utils.String(correlationID) + } + + if messageID != "" { + correlationFilter.MessageID = utils.String(messageID) + } + + if to != "" { + correlationFilter.To = utils.String(to) + } + + if replyTo != "" { + correlationFilter.ReplyTo = utils.String(replyTo) + } + + if label != "" { + correlationFilter.Label = utils.String(label) + } + + if sessionID != "" { + correlationFilter.SessionID = utils.String(sessionID) + } + + if replyToSessionID != "" { + correlationFilter.ReplyToSessionID = utils.String(replyToSessionID) + } + + if contentType != "" { + correlationFilter.ContentType = utils.String(contentType) } return &correlationFilter, nil diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index ff5f9c94b546f..691df7c925df4 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -4,9 +4,9 @@ import ( "bytes" "fmt" "log" - "strings" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute" + "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/structure" @@ -69,14 +69,15 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { }, "sku": { - Type: schema.TypeSet, + Type: schema.TypeList, Required: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, "tier": { @@ -92,7 +93,6 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { }, }, }, - Set: resourceArmVirtualMachineScaleSetSkuHash, }, "license_type": { @@ -1323,21 +1323,6 @@ func resourceArmVirtualMachineScaleSetStorageProfileImageReferenceHash(v interfa return hashcode.String(buf.String()) } -func resourceArmVirtualMachineScaleSetSkuHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - buf.WriteString(fmt.Sprintf("%s-", m["name"].(string))) - buf.WriteString(fmt.Sprintf("%d-", m["capacity"].(int))) - - if v, ok := m["tier"]; ok { - buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(v.(string)))) - } - } - - return hashcode.String(buf.String()) -} - func resourceArmVirtualMachineScaleSetStorageProfileOsDiskHash(v interface{}) int { var buf bytes.Buffer @@ -1418,20 +1403,15 @@ func resourceArmVirtualMachineScaleSetExtensionHash(v interface{}) int { } func expandVirtualMachineScaleSetSku(d *schema.ResourceData) (*compute.Sku, error) { - skuConfig := d.Get("sku").(*schema.Set).List() - + skuConfig := d.Get("sku").([]interface{}) config := skuConfig[0].(map[string]interface{}) - name := config["name"].(string) - tier := config["tier"].(string) - capacity := int64(config["capacity"].(int)) - sku := &compute.Sku{ - Name: &name, - Capacity: &capacity, + Name: utils.String(config["name"].(string)), + Capacity: utils.Int64(int64(config["capacity"].(int))), } - if tier != "" { + if tier, ok := config["tier"].(string); ok && tier != "" { sku.Tier = &tier } diff --git a/website/docs/r/application_insights.html.markdown b/website/docs/r/application_insights.html.markdown index 69041b5c420a0..dfe42114075b9 100644 --- a/website/docs/r/application_insights.html.markdown +++ b/website/docs/r/application_insights.html.markdown @@ -46,7 +46,7 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. -* `application_type` - (Required) Specifies the type of Application Insights to create. Valid values are `Web` and `Other`. +* `application_type` - (Required) Specifies the type of Application Insights to create. Valid values are `Web`, `Java`, `Phone`, `Store`, `iOS` and `Other`. * `tags` - (Optional) A mapping of tags to assign to the resource.