From 51db8c55abd2a70234299c7228b023fd79e7ff2a Mon Sep 17 00:00:00 2001 From: Michal Jura Date: Thu, 14 Nov 2024 12:33:47 +0100 Subject: [PATCH] Add OutBound Type to aks_config_v2 (#1439) Signed-off-by: Michal Jura --- docs/resources/cluster.md | 2 ++ rancher2/schema_cluster_aks_config_v2.go | 12 ++++++++++++ rancher2/structure_cluster_aks_config_v2.go | 6 ++++++ rancher2/structure_cluster_aks_config_v2_test.go | 2 ++ 4 files changed, 22 insertions(+) diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 8260c239..141ff1d8 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -553,6 +553,7 @@ resource "rancher2_cluster" "foo" { virtual_network_resource_group = "" subnet = "" node_resource_group = "" + outbound_type = "loadBalancer" node_pools { availability_zones = ["1", "2", "3"] name = "" @@ -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) diff --git a/rancher2/schema_cluster_aks_config_v2.go b/rancher2/schema_cluster_aks_config_v2.go index 60d4fce3..6beec1ef 100644 --- a/rancher2/schema_cluster_aks_config_v2.go +++ b/rancher2/schema_cluster_aks_config_v2.go @@ -2,6 +2,7 @@ package rancher2 import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" ) const ( @@ -9,6 +10,10 @@ const ( clusterDriverAKSV2 = "AKS" ) +var ( + clusterAKSOutboundType = []string{"loadbalancer", "managednatgateway", "userassignednatgateway", "userdefinedrouting"} +) + //Schemas func clusterAKSConfigV2NodePoolsFields() map[string]*schema.Schema { @@ -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, diff --git a/rancher2/structure_cluster_aks_config_v2.go b/rancher2/structure_cluster_aks_config_v2.go index 94ffe9bf..738e3a16 100644 --- a/rancher2/structure_cluster_aks_config_v2.go +++ b/rancher2/structure_cluster_aks_config_v2.go @@ -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 } @@ -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 } diff --git a/rancher2/structure_cluster_aks_config_v2_test.go b/rancher2/structure_cluster_aks_config_v2_test.go index 840e4067..60fe04dc 100644 --- a/rancher2/structure_cluster_aks_config_v2_test.go +++ b/rancher2/structure_cluster_aks_config_v2_test.go @@ -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", @@ -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",