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

Add OutBound Type to aks_config_v2 (#1439) #1444

Merged
merged 1 commit into from
Nov 15, 2024
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: 2 additions & 0 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ resource "rancher2_cluster" "foo" {
virtual_network_resource_group = "<virtual-network-resource-group>"
subnet = "<subnet>"
node_resource_group = "<node-resource-group>"
outbound_type = "loadBalancer"
node_pools {
availability_zones = ["1", "2", "3"]
name = "<nodepool-name-1>"
Expand Down Expand Up @@ -1550,6 +1551,7 @@ The following arguments are supported just for creating new AKS clusters (`impor
* `network_policy` - (Optional/Computed) The AKS network policy (string)
* `network_service_cidr` - (Optional/Computed) The AKS network service cidr (string)
* `node_resource_group` (Optional/Computed) The AKS node resource group name (string)
* `outbound_type` (Optional/Computed) The AKS outbound type for the egress traffic (string)
* `private_cluster` - (Optional/Computed) Is AKS cluster private? (bool)
* `subnet` - (Optional/Computed) The AKS subnet (string)
* `tags` - (Optional/Computed) The AKS cluster tags (map)
Expand Down
12 changes: 12 additions & 0 deletions rancher2/schema_cluster_aks_config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ package rancher2

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

const (
clusterAKSV2Kind = "aksV2"
clusterDriverAKSV2 = "AKS"
)

var (
clusterAKSOutboundType = []string{"loadbalancer", "managednatgateway", "userassignednatgateway", "userdefinedrouting"}
)

//Schemas

func clusterAKSConfigV2NodePoolsFields() map[string]*schema.Schema {
Expand Down Expand Up @@ -263,6 +268,13 @@ func clusterAKSConfigV2Fields() map[string]*schema.Schema {
Computed: true,
Description: "The AKS node resource group name",
},
"outboung_type": {
Type: schema.TypeString,
Optional: true,
Default: "loadBalancer",
Description: "The AKS outbound type for the egress traffic",
ValidateFunc: validation.StringInSlice(clusterAKSOutboundType, true),
},
"private_cluster": {
Type: schema.TypeBool,
Optional: true,
Expand Down
6 changes: 6 additions & 0 deletions rancher2/structure_cluster_aks_config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func flattenClusterAKSConfigV2(in *managementClient.AKSClusterConfigSpec, p []in
if in.NodeResourceGroup != nil && len(*in.NodeResourceGroup) > 0 {
obj["node_resource_group"] = *in.NodeResourceGroup
}
if in.OutboundType != nil && len(*in.OutboundType) > 0 {
obj["outbound_type"] = *in.OutboundType
}
if in.PrivateCluster != nil {
obj["private_cluster"] = *in.PrivateCluster
}
Expand Down Expand Up @@ -352,6 +355,9 @@ func expandClusterAKSConfigV2(p []interface{}) *managementClient.AKSClusterConfi
if v, ok := in["node_resource_group"].(string); ok && len(v) > 0 {
obj.NodeResourceGroup = &v
}
if v, ok := in["outbound_type"].(string); ok && len(v) > 0 {
obj.OutboundType = &v
}
if v, ok := in["subnet"].(string); ok && len(v) > 0 {
obj.Subnet = &v
}
Expand Down
2 changes: 2 additions & 0 deletions rancher2/structure_cluster_aks_config_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func init() {
NetworkServiceCIDR: newString("network_service_cidr"),
NodePools: testClusterAKSConfigV2NodePoolConf,
NodeResourceGroup: newString("node_resource_group"),
OutboundType: newString("loadBalancer"),
PrivateCluster: newTrue(),
ResourceGroup: "resource_group",
ResourceLocation: "resource_location",
Expand Down Expand Up @@ -122,6 +123,7 @@ func init() {
"network_service_cidr": "network_service_cidr",
"node_pools": testClusterAKSConfigV2NodePoolInterface,
"node_resource_group": "node_resource_group",
"outbound_type": "loadBalancer",
"private_cluster": true,
"resource_group": "resource_group",
"resource_location": "resource_location",
Expand Down