Coming two lists into one

I’m having a very simple requirement but I have a tough time to make it work…

Basically I have a list like this:

MACHINES:
[ { name: “Test1”, ip: “192.168.1.100”},
{ name: “Test2”, ip: “192.168.1.101”},
]

I then query AWS to get a list of machines back in a registered variable. What I want to do is to loop over this this registered variable to get InstanceID for any matching host with my MACHINES, then tag it with the Name in MACHINES. Can anyone advise on how I can achieve this?

Thanks,

Stanley