diff --git a/azurerm/resource_arm_traffic_manager_profile.go b/azurerm/resource_arm_traffic_manager_profile.go index debf33f7e1e87..dbdf4d8dfe8f0 100644 --- a/azurerm/resource_arm_traffic_manager_profile.go +++ b/azurerm/resource_arm_traffic_manager_profile.go @@ -88,9 +88,11 @@ func resourceArmTrafficManagerProfile() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - "http", - "https", - }, false), + string(trafficmanager.HTTP), + string(trafficmanager.HTTPS), + string(trafficmanager.TCP), + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, "port": { Type: schema.TypeInt, @@ -99,7 +101,7 @@ func resourceArmTrafficManagerProfile() *schema.Resource { }, "path": { Type: schema.TypeString, - Required: true, + Optional: true, }, }, }, diff --git a/azurerm/resource_arm_traffic_manager_profile_test.go b/azurerm/resource_arm_traffic_manager_profile_test.go index 503c1dda3064f..644202e3d7e04 100644 --- a/azurerm/resource_arm_traffic_manager_profile_test.go +++ b/azurerm/resource_arm_traffic_manager_profile_test.go @@ -47,6 +47,33 @@ func TestAccAzureRMTrafficManagerProfile_weighted(t *testing.T) { }) } +func TestAccAzureRMTrafficManagerProfile_weightedTCP(t *testing.T) { + resourceName := "azurerm_traffic_manager_profile.test" + ri := acctest.RandInt() + config := testAccAzureRMTrafficManagerProfile_weightedTCP(ri, testLocation()) + + fqdn, err := getTrafficManagerFQDN(fmt.Sprintf("acctesttmp%d", ri)) + if err != nil { + t.Fatalf("Error obtaining Azure Region: %+v", err) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMTrafficManagerProfileDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMTrafficManagerProfileExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "traffic_routing_method", "Weighted"), + resource.TestCheckResourceAttr(resourceName, "fqdn", fqdn), + ), + }, + }, + }) +} + func TestAccAzureRMTrafficManagerProfile_performance(t *testing.T) { resourceName := "azurerm_traffic_manager_profile.test" ri := acctest.RandInt() @@ -215,6 +242,31 @@ resource "azurerm_traffic_manager_profile" "test" { `, rInt, location, rInt, rInt) } +func testAccAzureRMTrafficManagerProfile_weightedTCP(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_traffic_manager_profile" "test" { + name = "acctesttmp%d" + resource_group_name = "${azurerm_resource_group.test.name}" + traffic_routing_method = "Weighted" + + dns_config { + relative_name = "acctesttmp%d" + ttl = 30 + } + + monitor_config { + protocol = "tcp" + port = 443 + } +} +`, rInt, location, rInt, rInt) +} + func testAccAzureRMTrafficManagerProfile_performance(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/website/docs/r/traffic_manager_profile.html.markdown b/website/docs/r/traffic_manager_profile.html.markdown index 57951a89fa37e..ca5d52196c8a4 100644 --- a/website/docs/r/traffic_manager_profile.html.markdown +++ b/website/docs/r/traffic_manager_profile.html.markdown @@ -89,11 +89,11 @@ The `dns_config` block supports: The `monitor_config` block supports: * `protocol` - (Required) The protocol used by the monitoring checks, supported - values are `http` or `https`. + values are `HTTP`, `HTTPS` and `TCP``. * `port` - (Required) The port number used by the monitoring checks. -* `path` - (Required) The path used by the monitoring checks. +* `path` - (Optional) The path used by the monitoring checks. Required when `protocol` is set to `HTTP` or `HTTPS` - cannot be set when `protocol` is set to `TCP`. ## Attributes Reference