Skip to content

Commit 21d8afb

Browse files
committed
Fix update logic
1 parent 8770385 commit 21d8afb

File tree

1 file changed

+14
-9
lines changed
  • pkg/resource/managed_prefix_list

1 file changed

+14
-9
lines changed

pkg/resource/managed_prefix_list/hooks.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ func (rm *resourceManager) customUpdateManagedPrefixList(
7474
// Build the modify input
7575
input := &svcsdk.ModifyManagedPrefixListInput{}
7676
input.PrefixListId = latest.ko.Status.ID
77-
input.PrefixListName = desired.ko.Spec.Name
7877

79-
// Convert MaxEntries from int64 to int32 if present
80-
if desired.ko.Spec.MaxEntries != nil {
81-
maxEntriesCopy := int32(*desired.ko.Spec.MaxEntries)
82-
input.MaxEntries = &maxEntriesCopy
78+
// Only set fields that actually changed
79+
if delta.DifferentAt("Spec.Name") {
80+
input.PrefixListName = desired.ko.Spec.Name
81+
}
82+
83+
if delta.DifferentAt("Spec.MaxEntries") {
84+
if desired.ko.Spec.MaxEntries != nil {
85+
maxEntriesCopy := int32(*desired.ko.Spec.MaxEntries)
86+
input.MaxEntries = &maxEntriesCopy
87+
}
8388
}
8489

8590
// Handle entries changes
@@ -98,11 +103,11 @@ func (rm *resourceManager) customUpdateManagedPrefixList(
98103
if len(removeEntries) > 0 {
99104
input.RemoveEntries = removeEntries
100105
}
106+
}
101107

102-
// Set current version for optimistic locking (required by AWS)
103-
if latest.ko.Status.Version != nil {
104-
input.CurrentVersion = latest.ko.Status.Version
105-
}
108+
// Set current version for optimistic locking (required by AWS for any modification)
109+
if latest.ko.Status.Version != nil {
110+
input.CurrentVersion = latest.ko.Status.Version
106111
}
107112

108113
// Only call ModifyManagedPrefixList if there are actual changes

0 commit comments

Comments
 (0)