refactor(ec2): drop each peering side's tags through removeTags (#8436)

This commit is contained in:
soreavis authored and GitHub committed 2026-11-15 08:47:43 -04:00
1 parent ff467b2e09
commit 3eadbef7a5
1 file changed
+3 -12
@@ -3135,13 +3135,8 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
// Tags are per account and per region, so each side keeps its own; both go with the attachment.
TransitGatewayPeeringAttachment.TgwInfo requester = attachment.getRequesterTgwInfo();
TransitGatewayPeeringAttachment.TgwInfo accepter = attachment.getAccepterTgwInfo();
if (tags instanceof AccountAwareStorageBackend<?> tagsByAccount) {
tagsByAccount.deleteForAccount(requester.getOwnerId(), key(requester.getRegion(), attachmentId));
tagsByAccount.deleteForAccount(accepter.getOwnerId(), key(accepter.getRegion(), attachmentId));
} else {
removeTags(requester.getRegion(), attachmentId);
removeTags(accepter.getRegion(), attachmentId);
}
removeTags(requester.getOwnerId(), requester.getRegion(), attachmentId);
removeTags(accepter.getOwnerId(), accepter.getRegion(), attachmentId);
attachment.setState("deleted");
return attachment;
}
@@ -12917,11 +12912,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
if (side == null || side.getRegion() == null) {
continue;
}
if (tags instanceof AccountAwareStorageBackend<?> tagsByAccount && side.getOwnerId() != null) {
tagsByAccount.deleteForAccount(side.getOwnerId(), key(side.getRegion(), id));
} else {
removeTags(side.getRegion(), id);
}
removeTags(side.getOwnerId(), side.getRegion(), id);
}
}