@@ -121,20 +121,24 @@ func AdjustRegionConfigsChildren(ctx context.Context, diags *diag.Diagnostics, s
121121 for j := range minLen (planRegionConfigsTF , stateRegionConfigsTF ) {
122122 stateReadOnlySpecs := TFModelObject [TFSpecsModel ](ctx , stateRegionConfigsTF [j ].ReadOnlySpecs )
123123 planReadOnlySpecs := TFModelObject [TFSpecsModel ](ctx , planRegionConfigsTF [j ].ReadOnlySpecs )
124+ planElectableSpecs := TFModelObject [TFSpecsModel ](ctx , planRegionConfigsTF [j ].ElectableSpecs )
124125 if stateReadOnlySpecs != nil { // read_only_specs is present in state
125126 newPlanReadOnlySpecs := planReadOnlySpecs
126127 if newPlanReadOnlySpecs == nil {
127128 newPlanReadOnlySpecs = new (TFSpecsModel ) // start with null attributes if not present plan
128129 }
129- baseReadOnlySpecs := stateReadOnlySpecs
130- if planElectableSpecInReplicationSpec != nil { // if electable_specs in any region config is in plan we rely on those values for updating known values
130+ baseReadOnlySpecs := stateReadOnlySpecs // using values directly from state if no electable specs are present in plan
131+ if planElectableSpecInReplicationSpec != nil { // ensures values are taken from a defined electable spec if not present in current region config
131132 baseReadOnlySpecs = planElectableSpecInReplicationSpec
132133 }
134+ if planElectableSpecs != nil { // we favour plan electable spec defined in same region config over one defined in replication spec to be more future proof baseReadOnlySpecs = planElectableSpecs
135+ baseReadOnlySpecs = planElectableSpecs
136+ }
133137 copyAttrIfDestNotKnown (& baseReadOnlySpecs .DiskSizeGb , & newPlanReadOnlySpecs .DiskSizeGb )
134138 copyAttrIfDestNotKnown (& baseReadOnlySpecs .EbsVolumeType , & newPlanReadOnlySpecs .EbsVolumeType )
135139 copyAttrIfDestNotKnown (& baseReadOnlySpecs .InstanceSize , & newPlanReadOnlySpecs .InstanceSize )
136140 copyAttrIfDestNotKnown (& baseReadOnlySpecs .DiskIops , & newPlanReadOnlySpecs .DiskIops )
137- // unknown node_count is got from state, all other unknowns are got from electable_specs plan or state if absent
141+ // unknown node_count is always taken from state as it not dependent on electable_specs changes
138142 copyAttrIfDestNotKnown (& stateReadOnlySpecs .NodeCount , & newPlanReadOnlySpecs .NodeCount )
139143 objType , diagsLocal := types .ObjectValueFrom (ctx , SpecsObjType .AttrTypes , newPlanReadOnlySpecs )
140144 diags .Append (diagsLocal ... )
0 commit comments