Azure - Terraform - Sharing/using existing resources (not importing)


I’m fairly new to Terraform and I’ve been working through various guides and tutorials.

I’m at the stage where I can build resource groups with resources, but I would like to know how to add to the existing resources I’ve built with Terraform. Where I’m struggling is to understand how I add new resource groups, with resources such as a virtual machines, but use existing resources in another resource group, such as network resources. Can anyone point me in the direct of the specific documentation or video clips that could help me, please?

I’ve been doing net searches to try and find more information, but I feel I’m not using the correct terms as the results tend to be about importing existing Azure resources, which isn’t what I’m looking for.

Any guidance most welcome.


I posted this a few days ago and since then I think I worked this out using modules.

It can be closed, if that’s done on here.