How can i get a list of azure vm ids using terraform and then read them back one value at a time?

I need to get a list of all VM ids in an Azure subscription using Terraform then read them back one by one and feed one id at a time to a module to perform some tasks on it, how can i do this?