IAC deployment of Multiple resources to multiple environments as resource groups

Hi All, I have a Terraform code for multiple resources (VM, Storage accounts, Container apps etc…). I have a requirement of deploying all these resources in multiple resource groups as environements (Dev,QA and SAT), so i am looking how do I refactor my code to this requirement and if possible anyone who knows how to acheive this please share a sample code or structure for this configuration