Skip to content

Commit 652f3f4

Browse files
committed
change update-replica style
1 parent 08ebf41 commit 652f3f4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: pkg/resource/table/hooks_replica_updates.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ func createReplicaUpdate(replica *v1alpha1.CreateReplicationGroupMemberAction) s
196196
func updateReplicaUpdate(replica *v1alpha1.CreateReplicationGroupMemberAction) svcsdktypes.ReplicationGroupUpdate {
197197
replicaUpdate := svcsdktypes.ReplicationGroupUpdate{}
198198
updateAction := &svcsdktypes.UpdateReplicationGroupMemberAction{}
199-
isValidUpdate := false // updates to gsi without ProvisionedThroughputOverride are invalid
200199

201200
if replica.RegionName != nil {
202201
updateAction.RegionName = aws.String(*replica.RegionName)
@@ -205,20 +204,17 @@ func updateReplicaUpdate(replica *v1alpha1.CreateReplicationGroupMemberAction) s
205204

206205
if replica.KMSMasterKeyID != nil {
207206
updateAction.KMSMasterKeyId = aws.String(*replica.KMSMasterKeyID)
208-
isValidUpdate = true
209207
}
210208

211209
if replica.TableClassOverride != nil {
212210
updateAction.TableClassOverride = svcsdktypes.TableClass(*replica.TableClassOverride)
213-
isValidUpdate = true
214211
}
215212

216213
if replica.ProvisionedThroughputOverride != nil &&
217214
replica.ProvisionedThroughputOverride.ReadCapacityUnits != nil {
218215
updateAction.ProvisionedThroughputOverride = &svcsdktypes.ProvisionedThroughputOverride{
219216
ReadCapacityUnits: replica.ProvisionedThroughputOverride.ReadCapacityUnits,
220217
}
221-
isValidUpdate = true
222218
}
223219

224220
// Only include GSIs that have provisioned throughput overrides
@@ -232,16 +228,21 @@ func updateReplicaUpdate(replica *v1alpha1.CreateReplicationGroupMemberAction) s
232228
ReadCapacityUnits: gsi.ProvisionedThroughputOverride.ReadCapacityUnits,
233229
},
234230
})
235-
isValidUpdate = true
236231
}
237232
}
238233

239-
// Only set GlobalSecondaryIndexes if we have GSIs with throughput overrides
240234
if len(gsisWithOverrides) > 0 {
241235
updateAction.GlobalSecondaryIndexes = gsisWithOverrides
242236
}
243237

244-
if isValidUpdate {
238+
// Check if there are any actual updates to perform
239+
// replica GSI updates are invalid updates since the GSI already exists on the source table
240+
hasUpdates := updateAction.KMSMasterKeyId != nil ||
241+
updateAction.TableClassOverride != "" ||
242+
updateAction.ProvisionedThroughputOverride != nil ||
243+
len(updateAction.GlobalSecondaryIndexes) > 0
244+
245+
if hasUpdates {
245246
replicaUpdate.Update = updateAction
246247
return replicaUpdate
247248
}

0 commit comments

Comments
 (0)