Skip to content

Commit

Permalink
New Resource: azurerm_kubernetes_cluster_node_pool
Browse files Browse the repository at this point in the history
Co-authored-by: titilambert <titilambert@ttb.lt>
Co-authored-by: djsly <sylvain.boily@gmail.com>

This commit rebases @titilambert's original commits on top of #4898
In addition it also makes a couple of changes:

- The resource has been renamed `azurerm_kubernetes_cluster_node_pool` to match
  the latest terminology used in the Portal
- The tests have been updated to use a Default Node Pool block in the AKS resource
- During creation we now check for the presence of the parent Cluster and then
  confirm that the Default Node Pool is a VirtualMachineScaleSet type
- Removes support for `orchestrator_version` temporarily - since this wants to be
  added to both the Default Node Pool and this resource at the same time/in the same PR
  since this wants some more specific tests (which'd be easier to review in a separate PR)
- Matches the name/schema for all fields with the `default_node_pool` block in the AKS resource

I've ended up `git reset HEAD~N` here to work around the merge conflict due to the large changes
within the AKS resource in #4898, but this seemed like the most pragmatic way to ship these changes.
  • Loading branch information
tombuildsstuff committed Nov 20, 2019
1 parent d928e22 commit 5cdb3b7
Show file tree
Hide file tree
Showing 7 changed files with 1,823 additions and 2 deletions.
45 changes: 45 additions & 0 deletions azurerm/internal/services/containers/nodepool_id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package containers

import (
"fmt"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)

type KubernetesNodePoolID struct {
Name string
ClusterName string
ResourceGroup string

ID azure.ResourceID
}

func ParseKubernetesNodePoolID(id string) (*KubernetesNodePoolID, error) {
clusterId, err := azure.ParseAzureResourceID(id)
if err != nil {
return nil, err
}

resourceGroup := clusterId.ResourceGroup
if resourceGroup == "" {
return nil, fmt.Errorf("%q is missing a Resource Group", id)
}

clusterName := clusterId.Path["managedClusters"]
if clusterName == "" {
return nil, fmt.Errorf("%q is missing the `managedClusters` segment", id)
}

nodePoolName := clusterId.Path["agentPools"]
if nodePoolName == "" {
return nil, fmt.Errorf("%q is missing the `agentPools` segment", id)
}

output := KubernetesNodePoolID{
Name: nodePoolName,
ClusterName: clusterName,
ResourceGroup: resourceGroup,
ID: *clusterId,
}
return &output, nil
}
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_key_vault_secret": resourceArmKeyVaultSecret(),
"azurerm_key_vault": resourceArmKeyVault(),
"azurerm_kubernetes_cluster": resourceArmKubernetesCluster(),
"azurerm_kubernetes_cluster_node_pool": resourceArmKubernetesClusterNodePool(),
"azurerm_kusto_cluster": resourceArmKustoCluster(),
"azurerm_kusto_database": resourceArmKustoDatabase(),
"azurerm_kusto_eventhub_data_connection": resourceArmKustoEventHubDataConnection(),
Expand Down

0 comments on commit 5cdb3b7

Please sign in to comment.