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

azurerm_batch_pool - frontend_port_range is now set correctly. #5941

Merged
merged 3 commits into from
Mar 2, 2020
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
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ func FlattenBatchPoolNetworkConfiguration(networkConfig *batch.NetworkConfigurat
inboundNatPoolMap["backend_port"] = *inboundNatPool.BackendPort
}
if inboundNatPool.FrontendPortRangeStart != nil && inboundNatPool.FrontendPortRangeEnd != nil {
inboundNatPoolMap["frontend_port_range"] = fmt.Sprintf("%d-%d", *inboundNatPool.FrontendPortRangeStart, inboundNatPool.FrontendPortRangeEnd)
inboundNatPoolMap["frontend_port_range"] = fmt.Sprintf("%d-%d", *inboundNatPool.FrontendPortRangeStart, *inboundNatPool.FrontendPortRangeEnd)
}
inboundNatPoolMap["protocol"] = inboundNatPool.Protocol

Expand Down
2 changes: 2 additions & 0 deletions azurerm/internal/services/batch/resource_arm_batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ func resourceArmBatchPoolRead(d *schema.ResourceData, meta interface{}) error {
}
}

d.Set("max_tasks_per_node", props.MaxTasksPerNode)

if props.DeploymentConfiguration != nil &&
props.DeploymentConfiguration.VirtualMachineConfiguration != nil &&
props.DeploymentConfiguration.VirtualMachineConfiguration.ImageReference != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,25 @@ func TestAccAzureRMBatchPool_customImage(t *testing.T) {
})
}

func TestAccAzureRMBatchPool_frontEndPortRanges(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_batch_pool", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMBatchPoolDestroy,
Steps: []resource.TestStep{
{
Config: testaccAzureRMBatchPool_networkConfiguration(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMBatchPoolExists(data.ResourceName),
),
},
data.ImportStep("stop_pending_resize_operation"),
},
})
}

func testCheckAzureRMBatchPoolExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
Expand Down Expand Up @@ -1158,3 +1177,68 @@ resource "azurerm_batch_pool" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomString, data.RandomString)
}

func testaccAzureRMBatchPool_networkConfiguration(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "testaccRG-%d-batchpool"
location = "%s"
}

resource "azurerm_virtual_network" "test" {
name = "acctestvirtnet%d"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_subnet" "test" {
name = "internal"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.0.2.0/24"
}

resource "azurerm_batch_account" "test" {
name = "testaccbatch%s"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
}

resource "azurerm_batch_pool" "test" {
name = "testaccpool%s"
resource_group_name = "${azurerm_resource_group.test.name}"
account_name = "${azurerm_batch_account.test.name}"
node_agent_sku_id = "batch.node.ubuntu 16.04"
vm_size = "Standard_A1"

fixed_scale {
target_dedicated_nodes = 1
}

storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04.0-LTS"
version = "latest"
}

network_configuration {
subnet_id = "${azurerm_subnet.test.id}"

endpoint_configuration {
name = "SSH"
protocol = "TCP"
backend_port = 22
frontend_port_range = "4000-4100"

network_security_group_rules {
access = "Deny"
priority = 1001
source_address_prefix = "*"
}
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString, data.RandomString)
}