File tree 2 files changed +26
-4
lines changed
aws-redshiftserverless-namespace/src/main/java/software/amazon/redshiftserverless/namespace
aws-redshiftserverless-workgroup/src/main/java/software/amazon/redshiftserverless/workgroup
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -299,14 +299,25 @@ static UpdateTagsRequest translateToUpdateTagsRequest(final ResourceModel desire
299
299
final ResourceModel currentResourceState ) {
300
300
String resourceArn = currentResourceState .getNamespace ().getNamespaceArn ();
301
301
302
- List <Tag > toBeCreatedTags = desiredResourceState .getTags () == null ? Collections .emptyList () : desiredResourceState .getTags ()
302
+ // If desiredResourceState.getTags() is null, we should preserve existing tags
303
+ // This ensures that when CloudFormation doesn't specify tags in the update,
304
+ // we don't remove existing tags
305
+ final List <Tag > effectiveDesiredTags ;
306
+ if (desiredResourceState .getTags () == null && currentResourceState .getTags () != null ) {
307
+ // Preserve existing tags by using them as the desired tags
308
+ effectiveDesiredTags = currentResourceState .getTags ();
309
+ } else {
310
+ effectiveDesiredTags = desiredResourceState .getTags ();
311
+ }
312
+
313
+ List <Tag > toBeCreatedTags = effectiveDesiredTags == null ? Collections .emptyList () : effectiveDesiredTags
303
314
.stream ()
304
315
.filter (tag -> currentResourceState .getTags () == null || !currentResourceState .getTags ().contains (tag ))
305
316
.collect (Collectors .toList ());
306
317
307
318
List <Tag > toBeDeletedTags = currentResourceState .getTags () == null ? Collections .emptyList () : currentResourceState .getTags ()
308
319
.stream ()
309
- .filter (tag -> desiredResourceState . getTags () == null || !desiredResourceState . getTags () .contains (tag ))
320
+ .filter (tag -> effectiveDesiredTags == null || !effectiveDesiredTags .contains (tag ))
310
321
.collect (Collectors .toList ());
311
322
312
323
return UpdateTagsRequest .builder ()
Original file line number Diff line number Diff line change @@ -287,14 +287,25 @@ static UpdateTagsRequest translateToUpdateTagsRequest(final ResourceModel desire
287
287
final ResourceModel currentResourceState ) {
288
288
String resourceArn = currentResourceState .getWorkgroup ().getWorkgroupArn ();
289
289
290
- List <Tag > toBeCreatedTags = desiredResourceState .getTags () == null ? Collections .emptyList () : desiredResourceState .getTags ()
290
+ // If desiredResourceState.getTags() is null, we should preserve existing tags
291
+ // This ensures that when CloudFormation doesn't specify tags in the update,
292
+ // we don't remove existing tags
293
+ final List <Tag > effectiveDesiredTags ;
294
+ if (desiredResourceState .getTags () == null && currentResourceState .getTags () != null ) {
295
+ // Preserve existing tags by using them as the desired tags
296
+ effectiveDesiredTags = currentResourceState .getTags ();
297
+ } else {
298
+ effectiveDesiredTags = desiredResourceState .getTags ();
299
+ }
300
+
301
+ List <Tag > toBeCreatedTags = effectiveDesiredTags == null ? Collections .emptyList () : effectiveDesiredTags
291
302
.stream ()
292
303
.filter (tag -> currentResourceState .getTags () == null || !currentResourceState .getTags ().contains (tag ))
293
304
.collect (Collectors .toList ());
294
305
295
306
List <Tag > toBeDeletedTags = currentResourceState .getTags () == null ? Collections .emptyList () : currentResourceState .getTags ()
296
307
.stream ()
297
- .filter (tag -> desiredResourceState . getTags () == null || !desiredResourceState . getTags () .contains (tag ))
308
+ .filter (tag -> effectiveDesiredTags == null || !effectiveDesiredTags .contains (tag ))
298
309
.collect (Collectors .toList ());
299
310
300
311
return UpdateTagsRequest .builder ()
You can’t perform that action at this time.
0 commit comments