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: add support for public_address_provisioning_type #10036

Merged
merged 3 commits into from
Jan 4, 2021
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/internal/services/batch/batch_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package batch
import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
)

// expandBatchAccountKeyVaultReference expands Batch account KeyVault reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/batch/batch_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
15 changes: 11 additions & 4 deletions azurerm/internal/services/batch/batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
Expand Down Expand Up @@ -583,7 +583,7 @@ func ExpandBatchPoolNetworkConfiguration(list []interface{}) (*batch.NetworkConf

if v, ok := networkConfigValue["public_ips"]; ok {
publicIPsRaw := v.(*schema.Set).List()
networkConfiguration.PublicIPs = utils.ExpandStringSlice(publicIPsRaw)
networkConfiguration.PublicIPAddressConfiguration.IPAddressIds = utils.ExpandStringSlice(publicIPsRaw)
}

if v, ok := networkConfigValue["endpoint_configuration"]; ok {
Expand All @@ -594,6 +594,12 @@ func ExpandBatchPoolNetworkConfiguration(list []interface{}) (*batch.NetworkConf
networkConfiguration.EndpointConfiguration = endpoint
}

if v, ok := networkConfigValue["public_address_provisioning_type"]; ok {
if value := v.(string); value != "" {
networkConfiguration.PublicIPAddressConfiguration.Provision = batch.IPAddressProvisioningType(value)
}
}

return networkConfiguration, nil
}

Expand Down Expand Up @@ -676,8 +682,9 @@ func FlattenBatchPoolNetworkConfiguration(networkConfig *batch.NetworkConfigurat
result["subnet_id"] = *networkConfig.SubnetID
}

if networkConfig.PublicIPs != nil {
result["public_ips"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(networkConfig.PublicIPs))
if networkConfig.PublicIPAddressConfiguration != nil {
result["public_ips"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(networkConfig.PublicIPAddressConfiguration.IPAddressIds))
result["public_address_provisioning_type"] = string(networkConfig.PublicIPAddressConfiguration.Provision)
}

if cfg := networkConfig.EndpointConfiguration; cfg != nil && cfg.InboundNatPools != nil && len(*cfg.InboundNatPools) != 0 {
Expand Down
11 changes: 10 additions & 1 deletion azurerm/internal/services/batch/batch_pool_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down Expand Up @@ -413,6 +413,15 @@ func resourceBatchPool() *schema.Resource {
},
Set: schema.HashString,
},
"public_address_provisioning_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
string(batch.BatchManaged),
string(batch.UserManaged),
string(batch.NoPublicIPAddresses),
}, false),
},
"endpoint_configuration": {
Type: schema.TypeList,
Optional: true,
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/batch/client/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2020-03-01/batch"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading