Skip to content

Commit 825a41a

Browse files
pmcatomineystack72
authored andcommitted
provider/azurerm: fix update protocol for lb_probe (hashicorp#11125)
request_path had Computed enabled which prevented updating it to an empty value TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMLoadBalancerProbe -timeout 120m === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (119.63s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (122.50s) === RUN TestAccAzureRMLoadBalancerProbe_update --- PASS: TestAccAzureRMLoadBalancerProbe_update (129.98s) === RUN TestAccAzureRMLoadBalancerProbe_duplicate --- PASS: TestAccAzureRMLoadBalancerProbe_duplicate (115.22s) === RUN TestAccAzureRMLoadBalancerProbe_updateProtocol --- PASS: TestAccAzureRMLoadBalancerProbe_updateProtocol (127.25s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 614.657s
1 parent 2afc0c4 commit 825a41a

2 files changed

Lines changed: 103 additions & 1 deletion

File tree

builtin/providers/azurerm/resource_arm_loadbalancer_probe.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func resourceArmLoadBalancerProbe() *schema.Resource {
5454
"request_path": {
5555
Type: schema.TypeString,
5656
Optional: true,
57-
Computed: true,
5857
},
5958

6059
"interval_in_seconds": {

builtin/providers/azurerm/resource_arm_loadbalancer_probe_test.go

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,36 @@ func TestAccAzureRMLoadBalancerProbe_duplicate(t *testing.T) {
124124
})
125125
}
126126

127+
func TestAccAzureRMLoadBalancerProbe_updateProtocol(t *testing.T) {
128+
var lb network.LoadBalancer
129+
ri := acctest.RandInt()
130+
probeName := fmt.Sprintf("probe-%d", ri)
131+
132+
resource.Test(t, resource.TestCase{
133+
PreCheck: func() { testAccPreCheck(t) },
134+
Providers: testAccProviders,
135+
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
136+
Steps: []resource.TestStep{
137+
{
138+
Config: testAccAzureRMLoadBalancerProbe_updateProtocolBefore(ri, probeName),
139+
Check: resource.ComposeTestCheckFunc(
140+
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
141+
testCheckAzureRMLoadBalancerProbeExists(probeName, &lb),
142+
resource.TestCheckResourceAttr("azurerm_lb_probe.test", "protocol", "Http"),
143+
),
144+
},
145+
{
146+
Config: testAccAzureRMLoadBalancerProbe_updateProtocolAfter(ri, probeName),
147+
Check: resource.ComposeTestCheckFunc(
148+
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
149+
testCheckAzureRMLoadBalancerProbeExists(probeName, &lb),
150+
resource.TestCheckResourceAttr("azurerm_lb_probe.test", "protocol", "Tcp"),
151+
),
152+
},
153+
},
154+
})
155+
}
156+
127157
func testCheckAzureRMLoadBalancerProbeExists(natRuleName string, lb *network.LoadBalancer) resource.TestCheckFunc {
128158
return func(s *terraform.State) error {
129159
_, _, exists := findLoadBalancerProbeByName(lb, natRuleName)
@@ -293,3 +323,76 @@ resource "azurerm_lb_probe" "test2" {
293323
}
294324
`, rInt, rInt, rInt, rInt, probeName, probe2Name)
295325
}
326+
327+
func testAccAzureRMLoadBalancerProbe_updateProtocolBefore(rInt int, probeName string) string {
328+
return fmt.Sprintf(`
329+
resource "azurerm_resource_group" "test" {
330+
name = "acctestrg-%d"
331+
location = "West US"
332+
}
333+
334+
resource "azurerm_public_ip" "test" {
335+
name = "test-ip-%d"
336+
location = "West US"
337+
resource_group_name = "${azurerm_resource_group.test.name}"
338+
public_ip_address_allocation = "static"
339+
}
340+
341+
resource "azurerm_lb" "test" {
342+
name = "arm-test-loadbalancer-%d"
343+
location = "West US"
344+
resource_group_name = "${azurerm_resource_group.test.name}"
345+
346+
frontend_ip_configuration {
347+
name = "one-%d"
348+
public_ip_address_id = "${azurerm_public_ip.test.id}"
349+
}
350+
}
351+
352+
resource "azurerm_lb_probe" "test" {
353+
location = "West US"
354+
resource_group_name = "${azurerm_resource_group.test.name}"
355+
loadbalancer_id = "${azurerm_lb.test.id}"
356+
name = "%s"
357+
protocol = "Http"
358+
request_path = "/"
359+
port = 80
360+
}
361+
`, rInt, rInt, rInt, rInt, probeName)
362+
}
363+
364+
func testAccAzureRMLoadBalancerProbe_updateProtocolAfter(rInt int, probeName string) string {
365+
return fmt.Sprintf(`
366+
resource "azurerm_resource_group" "test" {
367+
name = "acctestrg-%d"
368+
location = "West US"
369+
}
370+
371+
resource "azurerm_public_ip" "test" {
372+
name = "test-ip-%d"
373+
location = "West US"
374+
resource_group_name = "${azurerm_resource_group.test.name}"
375+
public_ip_address_allocation = "static"
376+
}
377+
378+
resource "azurerm_lb" "test" {
379+
name = "arm-test-loadbalancer-%d"
380+
location = "West US"
381+
resource_group_name = "${azurerm_resource_group.test.name}"
382+
383+
frontend_ip_configuration {
384+
name = "one-%d"
385+
public_ip_address_id = "${azurerm_public_ip.test.id}"
386+
}
387+
}
388+
389+
resource "azurerm_lb_probe" "test" {
390+
location = "West US"
391+
resource_group_name = "${azurerm_resource_group.test.name}"
392+
loadbalancer_id = "${azurerm_lb.test.id}"
393+
name = "%s"
394+
protocol = "Tcp"
395+
port = 80
396+
}
397+
`, rInt, rInt, rInt, rInt, probeName)
398+
}

0 commit comments

Comments
 (0)