HEAT template to attach an unknown number of ports (opened on different networks) to a server

I am trying to open as many number of ports(OS::Neutron::Port) on the provider networks mentioned by the user(via the parameter file) and trying to attach them to the server(OS::Nova::Server) that is being created.
How to achieve the above requirement?

My attempt: I gave a try using the OS::Heat::ResourceGroup by creating all the required network ports within a single ResourceGroup, but I wasn't able to iterate through them in order to attach it to the server.

Another attempt: Also, one more thing I tried was to declare a local variable in parameter section as a comma_delimited_list and used the same to hold the list that is returned by the function(get_attr: [port_group, refs]). But that approach reported that the comma_delimited_list variable is unknown