How can I safely migrate from inline security group rules to seperate security_group_rule resources

I initially set up my security groups as inline rules, but now realize there are a lot of problems with that. I want to migrate the security groups to use separate resources for the rules, however, when I do that it says it will remove the existing rules and recreate them. Since the security rules depend on the security group, I can’t even add the new rules first then remove the old ones.

How can I migrate the security group without temporarily removing all of the rules?