@@ -59,6 +59,39 @@ func ContainerengineClusterResource() *schema.Resource {
5959 },
6060
6161 // Optional
62+ "endpoint_config" : {
63+ Type : schema .TypeList ,
64+ Optional : true ,
65+ MaxItems : 1 ,
66+ MinItems : 1 ,
67+ Elem : & schema.Resource {
68+ Schema : map [string ]* schema.Schema {
69+ // Required
70+ "subnet_id" : {
71+ Type : schema .TypeString ,
72+ Required : true ,
73+ ForceNew : true ,
74+ },
75+
76+ // Optional
77+ "is_public_ip_enabled" : {
78+ Type : schema .TypeBool ,
79+ Optional : true ,
80+ Computed : true ,
81+ },
82+ "nsg_ids" : {
83+ Type : schema .TypeSet ,
84+ Optional : true ,
85+ Set : literalTypeHashCodeForSets ,
86+ Elem : & schema.Schema {
87+ Type : schema .TypeString ,
88+ },
89+ },
90+
91+ // Computed
92+ },
93+ },
94+ },
6295 "kms_key_id" : {
6396 Type : schema .TypeString ,
6497 Optional : true ,
@@ -194,6 +227,14 @@ func ContainerengineClusterResource() *schema.Resource {
194227 Type : schema .TypeString ,
195228 Computed : true ,
196229 },
230+ "private_endpoint" : {
231+ Type : schema .TypeString ,
232+ Computed : true ,
233+ },
234+ "public_endpoint" : {
235+ Type : schema .TypeString ,
236+ Computed : true ,
237+ },
197238 },
198239 },
199240 },
@@ -336,6 +377,17 @@ func (s *ContainerengineClusterResourceCrud) Create() error {
336377 request .CompartmentId = & tmp
337378 }
338379
380+ if endpointConfig , ok := s .D .GetOkExists ("endpoint_config" ); ok {
381+ if tmpList := endpointConfig .([]interface {}); len (tmpList ) > 0 {
382+ fieldKeyFormat := fmt .Sprintf ("%s.%d.%%s" , "endpoint_config" , 0 )
383+ tmp , err := s .mapToCreateClusterEndpointConfigDetails (fieldKeyFormat )
384+ if err != nil {
385+ return err
386+ }
387+ request .EndpointConfig = & tmp
388+ }
389+ }
390+
339391 if kmsKeyId , ok := s .D .GetOkExists ("kms_key_id" ); ok {
340392 tmp := kmsKeyId .(string )
341393 request .KmsKeyId = & tmp
@@ -525,10 +577,16 @@ func (s *ContainerengineClusterResourceCrud) Get() error {
525577}
526578
527579func (s * ContainerengineClusterResourceCrud ) Update () error {
528- request := oci_containerengine.UpdateClusterRequest {}
580+ clusterID := s .D .Id ()
581+ if endpointConfig , ok := s .D .GetOkExists ("endpoint_config" ); ok && s .D .HasChange ("endpoint_config" ) {
582+ err := s .updateClusterEndpointConfig (clusterID , endpointConfig )
583+ if err != nil {
584+ return err
585+ }
586+ }
529587
530- tmp := s . D . Id ()
531- request .ClusterId = & tmp
588+ request := oci_containerengine. UpdateClusterRequest {}
589+ request .ClusterId = & clusterID
532590
533591 if kubernetesVersion , ok := s .D .GetOkExists ("kubernetes_version" ); ok {
534592 tmp := kubernetesVersion .(string )
@@ -561,6 +619,26 @@ func (s *ContainerengineClusterResourceCrud) Update() error {
561619 workId := response .OpcWorkRequestId
562620 return s .getClusterFromWorkRequest (workId , getRetryPolicy (s .DisableNotFoundRetries , "containerengine" ), oci_containerengine .WorkRequestResourceActionTypeUpdated , s .D .Timeout (schema .TimeoutUpdate ))
563621}
622+ func (s * ContainerengineClusterResourceCrud ) updateClusterEndpointConfig (clusterID string , endpointConfig interface {}) error {
623+ request := oci_containerengine.UpdateClusterEndpointConfigRequest {}
624+ request .ClusterId = & clusterID
625+ if tmpList := endpointConfig .([]interface {}); len (tmpList ) > 0 {
626+ fieldKeyFormat := fmt .Sprintf ("%s.%d.%%s" , "endpoint_config" , 0 )
627+ tmp , err := s .mapToUpdateClusterEndpointConfigDetails (fieldKeyFormat )
628+ if err != nil {
629+ return err
630+ }
631+ request .UpdateClusterEndpointConfigDetails = tmp
632+ }
633+
634+ response , err := s .Client .UpdateClusterEndpointConfig (context .Background (), request )
635+ if err != nil {
636+ return err
637+ }
638+
639+ workID := response .OpcWorkRequestId
640+ return s .getClusterFromWorkRequest (workID , getRetryPolicy (s .DisableNotFoundRetries , "containerengine" ), oci_containerengine .WorkRequestResourceActionTypeUpdated , s .D .Timeout (schema .TimeoutUpdate ))
641+ }
564642
565643func (s * ContainerengineClusterResourceCrud ) Delete () error {
566644 request := oci_containerengine.DeleteClusterRequest {}
@@ -589,6 +667,12 @@ func (s *ContainerengineClusterResourceCrud) SetData() error {
589667 s .D .Set ("compartment_id" , * s .Res .CompartmentId )
590668 }
591669
670+ if s .Res .EndpointConfig != nil {
671+ s .D .Set ("endpoint_config" , []interface {}{ClusterEndpointConfigToMap (s .Res .EndpointConfig , false )})
672+ } else {
673+ s .D .Set ("endpoint_config" , nil )
674+ }
675+
592676 if s .Res .Endpoints != nil {
593677 s .D .Set ("endpoints" , []interface {}{ClusterEndpointsToMap (s .Res .Endpoints )})
594678 } else {
@@ -762,6 +846,14 @@ func ClusterEndpointsToMap(obj *oci_containerengine.ClusterEndpoints) map[string
762846 result ["kubernetes" ] = string (* obj .Kubernetes )
763847 }
764848
849+ if obj .PrivateEndpoint != nil {
850+ result ["private_endpoint" ] = string (* obj .PrivateEndpoint )
851+ }
852+
853+ if obj .PublicEndpoint != nil {
854+ result ["public_endpoint" ] = string (* obj .PublicEndpoint )
855+ }
856+
765857 return result
766858}
767859
@@ -807,6 +899,82 @@ func ClusterMetadataToMap(obj *oci_containerengine.ClusterMetadata) map[string]i
807899 return result
808900}
809901
902+ func (s * ContainerengineClusterResourceCrud ) mapToUpdateClusterEndpointConfigDetails (fieldKeyFormat string ) (oci_containerengine.UpdateClusterEndpointConfigDetails , error ) {
903+ result := oci_containerengine.UpdateClusterEndpointConfigDetails {}
904+ if isPublicIpEnabled , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "is_public_ip_enabled" )); ok {
905+ tmp := isPublicIpEnabled .(bool )
906+ result .IsPublicIpEnabled = & tmp
907+ }
908+ if nsgIds , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "nsg_ids" )); ok {
909+ set := nsgIds .(* schema.Set )
910+ interfaces := set .List ()
911+ tmp := make ([]string , len (interfaces ))
912+ for i := range interfaces {
913+ if interfaces [i ] != nil {
914+ tmp [i ] = interfaces [i ].(string )
915+ }
916+ }
917+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "nsg_ids" )) {
918+ result .NsgIds = tmp
919+ }
920+ }
921+ return result , nil
922+ }
923+
924+ func (s * ContainerengineClusterResourceCrud ) mapToCreateClusterEndpointConfigDetails (fieldKeyFormat string ) (oci_containerengine.CreateClusterEndpointConfigDetails , error ) {
925+ result := oci_containerengine.CreateClusterEndpointConfigDetails {}
926+
927+ if isPublicIpEnabled , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "is_public_ip_enabled" )); ok {
928+ tmp := isPublicIpEnabled .(bool )
929+ result .IsPublicIpEnabled = & tmp
930+ }
931+
932+ if nsgIds , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "nsg_ids" )); ok {
933+ set := nsgIds .(* schema.Set )
934+ interfaces := set .List ()
935+ tmp := make ([]string , len (interfaces ))
936+ for i := range interfaces {
937+ if interfaces [i ] != nil {
938+ tmp [i ] = interfaces [i ].(string )
939+ }
940+ }
941+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "nsg_ids" )) {
942+ result .NsgIds = tmp
943+ }
944+ }
945+
946+ if subnetId , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "subnet_id" )); ok {
947+ tmp := subnetId .(string )
948+ result .SubnetId = & tmp
949+ }
950+
951+ return result , nil
952+ }
953+
954+ func ClusterEndpointConfigToMap (obj * oci_containerengine.ClusterEndpointConfig , datasource bool ) map [string ]interface {} {
955+ result := map [string ]interface {}{}
956+
957+ if obj .IsPublicIpEnabled != nil {
958+ result ["is_public_ip_enabled" ] = bool (* obj .IsPublicIpEnabled )
959+ }
960+
961+ nsgIds := []interface {}{}
962+ for _ , item := range obj .NsgIds {
963+ nsgIds = append (nsgIds , item )
964+ }
965+ if datasource {
966+ result ["nsg_ids" ] = nsgIds
967+ } else {
968+ result ["nsg_ids" ] = schema .NewSet (literalTypeHashCodeForSets , nsgIds )
969+ }
970+
971+ if obj .SubnetId != nil {
972+ result ["subnet_id" ] = string (* obj .SubnetId )
973+ }
974+
975+ return result
976+ }
977+
810978func (s * ContainerengineClusterResourceCrud ) mapToKubernetesNetworkConfig (fieldKeyFormat string ) (oci_containerengine.KubernetesNetworkConfig , error ) {
811979 result := oci_containerengine.KubernetesNetworkConfig {}
812980
0 commit comments