Skip to content

Commit

Permalink
r/kubernetes_cluster: Only setting the VnetSubnetID when it's != "" (
Browse files Browse the repository at this point in the history
…#1158)

Fixes:

```
------- Stdout: -------
=== RUN   TestAccAzureRMKubernetesCluster_basic
--- FAIL: TestAccAzureRMKubernetesCluster_basic (55.13s)
    testing.go:513: Step 0 error: Error applying: 1 error(s) occurred:

        * azurerm_kubernetes_cluster.test: 1 error(s) occurred:

        * azurerm_kubernetes_cluster.test: containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="LinkedInvalidPropertyId" Message="Property id '' at path 'properties.agentPoolProfiles[0].vnetSubnetID' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'."
FAIL
```

Passing test:

```
$ acctests azurerm TestAccAzureRMKubernetesCluster_basic
=== RUN   TestAccAzureRMKubernetesCluster_basic
--- PASS: TestAccAzureRMKubernetesCluster_basic (1713.63s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	1713.661s
```
  • Loading branch information
tombuildsstuff authored Apr 24, 2018
1 parent 4084cb6 commit 7f993c9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions azurerm/resource_arm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,20 +441,23 @@ func expandAzureRmKubernetesClusterAgentProfiles(d *schema.ResourceData) []conta
dnsPrefix := config["dns_prefix"].(string)
vmSize := config["vm_size"].(string)
osDiskSizeGB := int32(config["os_disk_size_gb"].(int))
vnetSubnetID := config["vnet_subnet_id"].(string)
osType := config["os_type"].(string)

profile := containerservice.AgentPoolProfile{
Name: &name,
Count: &count,
Name: utils.String(name),
Count: utils.Int32(count),
VMSize: containerservice.VMSizeTypes(vmSize),
DNSPrefix: &dnsPrefix,
OsDiskSizeGB: &osDiskSizeGB,
DNSPrefix: utils.String(dnsPrefix),
OsDiskSizeGB: utils.Int32(osDiskSizeGB),
StorageProfile: containerservice.ManagedDisks,
VnetSubnetID: &vnetSubnetID,
OsType: containerservice.OSType(osType),
}

vnetSubnetID := config["vnet_subnet_id"].(string)
if vnetSubnetID != "" {
profile.VnetSubnetID = utils.String(vnetSubnetID)
}

profiles = append(profiles, profile)

return profiles
Expand Down

0 comments on commit 7f993c9

Please sign in to comment.