@@ -386,15 +386,15 @@ func resourceClusterEks() *schema.Resource {
386386 }
387387
388388 // No-op state upgrader to move from version 2 -> 3 (TypeList -> TypeSet for machine_pool)
389- r .StateUpgraders = []schema.StateUpgrader {
390- {
391- Version : 2 ,
392- Type : r .CoreConfigSchema ().ImpliedType (),
393- Upgrade : func (ctx context.Context , rawState map [string ]interface {}, meta interface {}) (map [string ]interface {}, error ) {
394- return rawState , nil
395- },
396- },
397- }
389+ // r.StateUpgraders = []schema.StateUpgrader{
390+ // {
391+ // Version: 2,
392+ // Type: r.CoreConfigSchema().ImpliedType(),
393+ // Upgrade: func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
394+ // return rawState, nil
395+ // },
396+ // },
397+ // }
398398
399399 return r
400400}
@@ -573,22 +573,42 @@ func flattenMachinePoolConfigsEks(machinePools []*models.V1EksMachinePoolConfig)
573573 oi ["max" ] = int (machinePool .MaxSize )
574574 oi ["instance_type" ] = machinePool .InstanceType
575575 oi ["ami_type" ] = machinePool .AmiType
576+
577+ // Always set capacity_type (with schema default if nil)
576578 if machinePool .CapacityType != nil {
577- oi ["capacity_type" ] = machinePool .CapacityType
579+ oi ["capacity_type" ] = * machinePool .CapacityType
580+ } else {
581+ oi ["capacity_type" ] = "on-demand" // matches schema default
578582 }
583+
584+ // Always set max_price (empty string if not spot)
579585 if machinePool .SpotMarketOptions != nil {
580586 oi ["max_price" ] = machinePool .SpotMarketOptions .MaxPrice
587+ } else {
588+ oi ["max_price" ] = ""
581589 }
590+
582591 oi ["disk_size_gb" ] = int (machinePool .RootDeviceSize )
592+
593+ // Always set both azs and az_subnets (one populated, other empty)
583594 if len (machinePool .SubnetIds ) > 0 {
584595 oi ["az_subnets" ] = machinePool .SubnetIds
596+ oi ["azs" ] = make ([]interface {}, 0 ) // empty array
585597 } else {
586- oi ["azs" ] = machinePool .Azs
598+ oi ["az_subnets" ] = make (map [string ]interface {}) // empty map
599+ if machinePool .Azs != nil {
600+ oi ["azs" ] = machinePool .Azs
601+ } else {
602+ oi ["azs" ] = make ([]interface {}, 0 ) // empty array
603+ }
587604 }
588- eksLaunchTemplates := flattenEksLaunchTemplate (machinePool .AwsLaunchTemplate )
589605
606+ // Always set eks_launch_template (empty array if not configured)
607+ eksLaunchTemplates := flattenEksLaunchTemplate (machinePool .AwsLaunchTemplate )
590608 if eksLaunchTemplates != nil {
591- oi ["eks_launch_template" ] = flattenEksLaunchTemplate (machinePool .AwsLaunchTemplate )
609+ oi ["eks_launch_template" ] = eksLaunchTemplates
610+ } else {
611+ oi ["eks_launch_template" ] = make ([]interface {}, 0 )
592612 }
593613
594614 ois = append (ois , oi )
0 commit comments