@@ -145,7 +145,6 @@ func resourceClusterEks() *schema.Resource {
145145 },
146146 "cloud_config" : {
147147 Type : schema .TypeList ,
148- ForceNew : true ,
149148 Required : true ,
150149 MaxItems : 1 ,
151150 Description : "The AWS environment configuration settings such as network parameters and encryption parameters that apply to this cluster." ,
@@ -200,7 +199,6 @@ func resourceClusterEks() *schema.Resource {
200199 "public_access_cidrs" : {
201200 Type : schema .TypeSet ,
202201 Optional : true ,
203- ForceNew : true ,
204202 Set : schema .HashString ,
205203 Description : "List of CIDR blocks that define the allowed public access to the resource. Requests originating from addresses within these CIDR blocks will be permitted to access the resource. All other addresses will be denied access." ,
206204 Elem : & schema.Schema {
@@ -210,7 +208,6 @@ func resourceClusterEks() *schema.Resource {
210208 "private_access_cidrs" : {
211209 Type : schema .TypeSet ,
212210 Optional : true ,
213- ForceNew : true ,
214211 Set : schema .HashString ,
215212 Description : "List of CIDR blocks that define the allowed private access to the resource. Only requests originating from addresses within these CIDR blocks will be permitted to access the resource." ,
216213 Elem : & schema.Schema {
@@ -511,6 +508,7 @@ func flattenClusterConfigsEKS(cloudConfig *models.V1EksCloudConfig) interface{}
511508 if pool .Name == "cp-pool" {
512509 ret ["az_subnets" ] = pool .SubnetIds
513510 }
511+
514512 }
515513
516514 if cloudConfig .Spec .ClusterConfig .EncryptionConfig != nil && cloudConfig .Spec .ClusterConfig .EncryptionConfig .IsEnabled {
@@ -659,6 +657,15 @@ func resourceClusterEksUpdate(ctx context.Context, d *schema.ResourceData, m int
659657 }
660658 cloudConfigId := d .Get ("cloud_config_id" ).(string )
661659
660+ if d .HasChange ("cloud_config" ) {
661+ cloudConfig := d .Get ("cloud_config" ).([]interface {})[0 ].(map [string ]interface {})
662+ cloudConfigEntity := toCloudConfigEks (cloudConfig )
663+ err := c .UpdateCloudConfigEks (cloudConfigId , cloudConfigEntity )
664+ if err != nil {
665+ return diag .FromErr (err )
666+ }
667+ }
668+
662669 CloudConfig , err := c .GetCloudConfigEks (cloudConfigId )
663670 if err != nil {
664671 return diag .FromErr (err )
@@ -830,6 +837,7 @@ func toEksCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro
830837 cluster .Spec .CloudConfig .EndpointAccess = access
831838
832839 machinePoolConfigs := make ([]* models.V1EksMachinePoolConfigEntity , 0 )
840+
833841 // Following same logic as UI for setting up control plane for static cluster
834842 // Only add cp-pool for dynamic cluster provisioning when az_subnets is not empty and has more than one element
835843 if cloudConfig ["az_subnets" ] != nil && len (cloudConfig ["az_subnets" ].(map [string ]interface {})) > 0 {
@@ -842,6 +850,7 @@ func toEksCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro
842850 }
843851 machinePoolConfigs = append (machinePoolConfigs , toMachinePoolEks (cpPool ))
844852 }
853+
845854 for _ , machinePool := range d .Get ("machine_pool" ).([]interface {}) {
846855 mp := toMachinePoolEks (machinePool )
847856 machinePoolConfigs = append (machinePoolConfigs , mp )
@@ -1050,3 +1059,55 @@ func toFargateProfileEks(fargateProfile interface{}) *models.V1FargateProfile {
10501059
10511060 return f
10521061}
1062+
1063+ func toCloudConfigEks (cloudConfig map [string ]interface {}) * models.V1EksCloudClusterConfigEntity {
1064+ var encryptionConfig * models.V1EncryptionConfig
1065+ if cloudConfig ["encryption_config_arn" ] != nil && cloudConfig ["encryption_config_arn" ].(string ) != "" {
1066+ encryptionConfig = & models.V1EncryptionConfig {
1067+ IsEnabled : true ,
1068+ Provider : cloudConfig ["encryption_config_arn" ].(string ),
1069+ }
1070+ }
1071+
1072+ access := & models.V1EksClusterConfigEndpointAccess {}
1073+ switch cloudConfig ["endpoint_access" ].(string ) {
1074+ case "public" :
1075+ access .Public = true
1076+ access .Private = false
1077+ case "private" :
1078+ access .Public = false
1079+ access .Private = true
1080+ case "private_and_public" :
1081+ access .Public = true
1082+ access .Private = true
1083+ }
1084+
1085+ if cloudConfig ["public_access_cidrs" ] != nil {
1086+ cidrs := make ([]string , 0 )
1087+ for _ , cidr := range cloudConfig ["public_access_cidrs" ].(* schema.Set ).List () {
1088+ cidrs = append (cidrs , cidr .(string ))
1089+ }
1090+ access .PublicCIDRs = cidrs
1091+ }
1092+
1093+ if cloudConfig ["private_access_cidrs" ] != nil {
1094+ cidrs := make ([]string , 0 )
1095+ for _ , cidr := range cloudConfig ["private_access_cidrs" ].(* schema.Set ).List () {
1096+ cidrs = append (cidrs , cidr .(string ))
1097+ }
1098+ access .PrivateCIDRs = cidrs
1099+ }
1100+
1101+ clusterConfigEntity := & models.V1EksCloudClusterConfigEntity {
1102+ ClusterConfig : & models.V1EksClusterConfig {
1103+ BastionDisabled : true ,
1104+ VpcID : cloudConfig ["vpc_id" ].(string ),
1105+ Region : types .Ptr (cloudConfig ["region" ].(string )),
1106+ SSHKeyName : cloudConfig ["ssh_key_name" ].(string ),
1107+ EncryptionConfig : encryptionConfig ,
1108+ EndpointAccess : access ,
1109+ },
1110+ }
1111+
1112+ return clusterConfigEntity
1113+ }
0 commit comments