@@ -195,7 +195,7 @@ export class ClusterResourceHandler extends ResourceHandler {
195195 return this . updateClusterVersion ( this . newProps . version ) ;
196196 }
197197
198- if ( updates . updateLogging || updates . updateAccess || updates . updateVpc || updates . updateAuthMode ) {
198+ if ( updates . updateLogging || updates . updateAccess || updates . updateVpc || updates . updateAuthMode || updates . updateRemoteNetworkConfig ) {
199199 const config : EKS . UpdateClusterConfigCommandInput = {
200200 name : this . clusterName ,
201201 } ;
@@ -262,6 +262,13 @@ export class ClusterResourceHandler extends ResourceHandler {
262262 } ;
263263 }
264264
265+ if ( updates . updateRemoteNetworkConfig ) {
266+ config . remoteNetworkConfig = {
267+ remoteNodeNetworks : this . newProps . remoteNetworkConfig ?. remoteNodeNetworks ,
268+ remotePodNetworks : this . newProps . remoteNetworkConfig ?. remotePodNetworks ,
269+ } ;
270+ }
271+
265272 const updateResponse = await this . eks . updateClusterConfig ( config ) ;
266273
267274 return { EksUpdateId : updateResponse . update ?. id } ;
@@ -415,6 +422,7 @@ interface UpdateMap {
415422 updateBootstrapClusterCreatorAdminPermissions : boolean ; // accessConfig.bootstrapClusterCreatorAdminPermissions
416423 updateVpc : boolean ; // resourcesVpcConfig.subnetIds and securityGroupIds
417424 updateTags : boolean ; // tags
425+ updateRemoteNetworkConfig : boolean ; // remoteNetworkConfig
418426}
419427
420428function analyzeUpdate ( oldProps : Partial < EKS . CreateClusterCommandInput > , newProps : EKS . CreateClusterCommandInput ) : UpdateMap {
@@ -431,6 +439,9 @@ function analyzeUpdate(oldProps: Partial<EKS.CreateClusterCommandInput>, newProp
431439 const newAccessConfig = newProps . accessConfig || { } ;
432440 const oldAccessConfig = oldProps . accessConfig || { } ;
433441
442+ const oldRemoteNetworkConfig = oldProps . remoteNetworkConfig || { } ;
443+ const newRemoteNetworkConfig = newProps . remoteNetworkConfig || { } ;
444+
434445 return {
435446 replaceName : newProps . name !== oldProps . name ,
436447 updateVpc :
@@ -448,6 +459,7 @@ function analyzeUpdate(oldProps: Partial<EKS.CreateClusterCommandInput>, newProp
448459 updateBootstrapClusterCreatorAdminPermissions : JSON . stringify ( newAccessConfig . bootstrapClusterCreatorAdminPermissions ) !==
449460 JSON . stringify ( oldAccessConfig . bootstrapClusterCreatorAdminPermissions ) ,
450461 updateTags : JSON . stringify ( newProps . tags ) !== JSON . stringify ( oldProps . tags ) ,
462+ updateRemoteNetworkConfig : ! compareRemoteNetworkConfigs ( oldRemoteNetworkConfig , newRemoteNetworkConfig ) ,
451463 } ;
452464}
453465
@@ -482,3 +494,54 @@ function getTagsToRemove<T extends Record<string, string>>(oldTags: T, newTags:
482494
483495 return missingKeys ;
484496}
497+
498+ function compareRemoteNetworkConfigs (
499+ oldConfig ?: EKS . RemoteNetworkConfigRequest | undefined ,
500+ newConfig ?: EKS . RemoteNetworkConfigRequest | undefined ,
501+ ) : boolean {
502+ if ( ! oldConfig && ! newConfig ) {
503+ return true ;
504+ }
505+
506+ if ( ! oldConfig || ! newConfig ) {
507+ return false ;
508+ }
509+
510+ const nodeNetworksEqual = compareNetworkArrays (
511+ oldConfig . remoteNodeNetworks ,
512+ newConfig . remoteNodeNetworks ,
513+ ) ;
514+
515+ const podNetworksEqual = compareNetworkArrays (
516+ oldConfig . remotePodNetworks ,
517+ newConfig . remotePodNetworks ,
518+ ) ;
519+
520+ return nodeNetworksEqual && podNetworksEqual ;
521+ }
522+
523+ function compareNetworkArrays (
524+ oldNetworks ?: ( EKS . RemoteNodeNetwork | EKS . RemotePodNetwork ) [ ] | undefined ,
525+ newNetworks ?: ( EKS . RemoteNodeNetwork | EKS . RemotePodNetwork ) [ ] | undefined ,
526+ ) : boolean {
527+ if ( ! oldNetworks && ! newNetworks ) {
528+ return true ;
529+ }
530+
531+ if ( ! oldNetworks || ! newNetworks ) {
532+ return false ;
533+ }
534+
535+ if ( oldNetworks . length !== newNetworks . length ) {
536+ return false ;
537+ }
538+
539+ const oldCidrs = oldNetworks . flatMap ( network => network . cidrs || [ ] ) . sort ( ) ;
540+ const newCidrs = newNetworks . flatMap ( network => network . cidrs || [ ] ) . sort ( ) ;
541+
542+ if ( oldCidrs . length !== newCidrs . length ) {
543+ return false ;
544+ }
545+
546+ return oldCidrs . every ( ( cidr , index ) => cidr === newCidrs [ index ] ) ;
547+ }
0 commit comments